Aligning A Textview And Imageview Inside A Linearlayout
I have a ListView with custom adapter and a layout for items in this List. The layout for the items is just a TextView with an ImageView. The image should be aligned to the right s
Solution 1:
RelativeLayout should solve your problem nicely using android:layout_alignParentRight
and android:layout_alignParentLeft
. Something like:
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/txtCategoryName"android:layout_alignParentLeft="true"android:layout_width="wrap_content"android:layout_height="wrap_content"android:singleLine="true"android:ellipsize="end"android:gravity="center_vertical"android:paddingTop="5dp"android:paddingBottom="5dp"android:textColor="@color/list_text_color"android:textAppearance="?android:attr/textAppearanceLarge" /><ImageViewandroid:id="@+id/imgArrowRight"android:layout_alignParentRight="true"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/right_arrow_44"android:contentDescription="@string/img_description_right_arrow"/>
Solution 2:
I think you try to use a RelativeLayout and using align parent right on the image and align parent left on the TextView.
Post a Comment for "Aligning A Textview And Imageview Inside A Linearlayout"