Aligning ImageView to right of the layout android

前端 未结 8 1165
生来不讨喜
生来不讨喜 2021-02-04 01:26

I have an layout




        
相关标签:
8条回答
  • 2021-02-04 01:53

    Use RelativeLayout as a parent layout.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent">
    
        <TextView android:id="@+id/groupname"
                  android:paddingLeft="50px"
                  android:textSize="16px"
                  android:textColor="#000000"
                  android:textStyle="normal"
                  android:layout_width="wrap_content"
                  android:layout_height="50px"/>
    
        <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="6dp"
                android:src="@drawable/ncc"/>
    
    </RelativeLayout>
    
    0 讨论(0)
  • 2021-02-04 01:55

    You can use drawableRight attribut to take it very simple like this example:

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="50px"
        android:textSize="16sp"
        android:textStyle="normal"
        android:drawableRight="@drawable/ic_favorite_gray"/>
    
    0 讨论(0)
提交回复
热议问题