I'm having difficulties in aligning center a text view below an image button though I tried the property android:gravity="center", the first two text views are aligned in center of the corresponding image buttons, but the third one didn't fit well here is my xml code:
<ImageView
android:id="@+id/view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:background="@null"
android:src="@drawable/imageview" />
<ImageButton
android:id="@+id/recBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textViewBook"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="107dp"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/recipebook" />
<TextView
android:id="@+id/textViewBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/recBook"
android:layout_marginLeft="33dp"
android:text="@string/BookTV"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageButton
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textViewBook"
android:layout_marginLeft="60dp"
android:layout_toRightOf="@+id/textViewBook"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/search" />
<TextView
android:id="@+id/textViewSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textViewBook"
android:layout_alignBottom="@+id/textViewBook"
android:layout_marginLeft="37dp"
android:layout_toRightOf="@+id/textViewBook"
android:text="@string/Search"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageButton
android:id="@+id/favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/recBook"
android:layout_centerVertical="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/favorites" />
<TextView
android:id="@+id/textViewFav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_="@+id/favorite"
android:layout_alignLeft="@+id/textViewBook"
android:layout_below="@+id/favorite"
android:text="@string/FavTV"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
Use RelativeLayout and use this:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageButton"
android:layout_centerInParent="true"
android:text="text" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With