I have an text view as show above and an info icon next to the text view. All is fine here but I wish to have the info icon aligned center to the textview. As of now it is aligned top right relative to the text view. I wish it to be aligned center right relative to the text view
The XML Layout file is below
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_gravity="center"
>
<TextView
android:id="@+id/ViewMessageOne"
android:layout_width="275dp"
android:layout_height="45dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textSize="14sp"
android:typeface="sans"
android:background="@drawable/back"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/banner_portrait"
android:layout_toRightOf="@+id/ViewMessageOne"
android:paddingLeft="10dp"
android:gravity="center"
/>
</RelativeLayout>
Please point me in the right direction. Thanks for your help
Try:
android:layout_gravity="center_vertical|right"
EDIT:
You could also just change the height to match the TextView
, as your ImageView
gravity is set to center
.
<ImageView
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_toRightOf="@+id/ViewMessageOne"
android:gravity="center"
android:paddingLeft="10dp"
android:src="@drawable/banner_portrait" />
Unless you have a specific need for the ImageView
, you could take that out and use drawableRigh on your TextView
<TextView
android:id="@+id/ViewMessageOne"
android:layout_width="275dp"
android:layout_height="45dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textSize="14sp"
android:typeface="sans"
android:background="@drawable/back"
android:drawableRight="@drawable/banner_portrait" // here
/>
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