I need to place 5 imageButton
s on top of the screen. I did it with LinarLayout
like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.terrormachine.swipeapp.NewAdFragment">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image"
android:id="@+id/imageButton6"
android:layout_weight="1"
android:scaleType="fitCenter" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image"
android:id="@+id/imageButton7"
android:layout_weight="1"
android:scaleType="fitCenter" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image"
android:id="@+id/imageButton8"
android:layout_weight="1"
android:scaleType="fitCenter" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image"
android:id="@+id/imageButton9"
android:layout_weight="1"
android:scaleType="fitCenter" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image"
android:id="@+id/imageButton10"
android:layout_weight="1"
android:scaleType="fitCenter" />
</LinearLayout>
</RelativeLayout>
Problem is I need to put text centered below every image. I tried several solutions and none seems to work for me. Ive tried this:
Android Text Below Icon (button) How to add a text under the image button in Android? How to place text below a Button or a ImageButton?
Some of them do the trick but images are not scaled. In my case I cant set text below. Is there any way to do this?
I don't HAVE to use LinearLayout
but I cannot figure any proper way to place them equally separated and with screen width. Any ideas are welcome.