Align text left, checkbox right

前端 未结 13 2278
孤街浪徒
孤街浪徒 2020-12-29 18:28

I\'m trying to create a layout for a ListView, with a checkbox to the right and some text to the left. The checkbox should be aligned all the way to the right and the TextV

相关标签:
13条回答
  • 2020-12-29 19:08

    If you're going to use a relativelayout you might want to consider using the less annoying relativelayout attributes, alignParentLeft and alignParentRight, like so:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
        android:paddingTop="8dip"
        android:paddingBottom="8dip"
    >
    
    <TextView  
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:alignParentLeft="true"
    />
    
    <CheckBox 
        android:id="@+id/chekcbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:alignParentRight="true"
    /> 
    
    </RelativeLayout>
    

    Just watch out for elements getting on top of other elements.

    0 讨论(0)
提交回复
热议问题