I am using a relative layout and want to align a TextView below and in the middle of a button as shown in the attached image. I have can get it to the bottom using BELOW, but cant figure out how to align their horizontal centers.
Easiest way is to put image and textview into a relative layout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:text="TextView" />
</RelativeLayout>
Edit
To do this in single Layout add android:drawableTop
to your TextView
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:drawableTop="@drawable/ic_launcher"/>
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