最大化宽度和复选框的Android布局
如何使布局像下面的图像-最大化的家长,但只有宽度,包装元素将适合在右边。我最终得到了如下xml中的布局,但当TextView较长时,它会与复选框重叠最大化宽度和复选框的Android布局,android,android-layout,Android,Android Layout,如何使布局像下面的图像-最大化的家长,但只有宽度,包装元素将适合在右边。我最终得到了如下xml中的布局,但当TextView较长时,它会与复选框重叠 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:l
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
在文本视图中,添加以下规则: android:toLeftOf=@+id/checkbox最后,我使用LinearLayout和android:layout\u-weight=1制作了这个
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:padding="5dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>