Android 如何自动对齐按钮
我想我的单选按钮自动对齐而不指定dp,如何做到这一点 在下面的示例中,设置了单选按钮宽度80和高度70。相反,我想这样做,比如填充父内容或包装内容。我该怎么办Android 如何自动对齐按钮,android,layout,Android,Layout,我想我的单选按钮自动对齐而不指定dp,如何做到这一点 在下面的示例中,设置了单选按钮宽度80和高度70。相反,我想这样做,比如填充父内容或包装内容。我该怎么办 <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:checkedButton="@+id/all
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="@+id/allcontacts"
android:id="@+id/contactgroup">
<RadioButton android:id="@+id/allcontacts"
android:width="80dip"
android:height="70dip"/>
<RadioButton android:id="@+id/categories"
android:width="80dip" android:height="70dip" />
<RadioButton android:id="@+id/favourites"
android:width="80dip" android:height="70dip" />
在按钮周围环绕一条线性布局。然后,如果需要,您可以使用填充来调整确切的位置将按钮以线性布局(水平)的形式进行包装,布局宽度为匹配
对于每个按钮,将布局高度设置为包裹内容,将布局宽度设置为0dp,将布局重量设置为1,所有按钮的大小都将相同。不要应用固定大小,而要应用
包裹内容
。不要只说“我想对齐”。。说你想要它如何对齐…我想要所有这些按钮以相等的间距水平对齐。我不想在dpSo中指定高度和宽度,你的意思是说,将这些按钮放在透镜布局中?是的。将线性布局包装在你使用的整个按钮中。你没有提到对齐按钮的类型,无论是水平还是垂直。