我正在制作一个api,其中我在我的xml文件中使用复选框.问题是我的复选框图标显示在左侧.但我想移动我的复选框右侧靠近文本"男性"或"女性".像这样..
但目前我变得像这样的观点..
我想在右边看我的checkicon选项..,我已经使用了这个代码..我的xml ...
谢谢..
在复选框中使用以下属性:
Set android:button="@null"; Set android:drawableRight="@drawable/YOUR_CHECKBOX_BUTTON"
希望它会奏效.
尝试这个..你可以使用CheckedTextView而不是CheckBox来满足你的需要..此外它几乎所有的属性都类似于CheckBox,这样你就可以通过java检查/取消选中它,而无需使用任何外部可绘制图像并更改它们的来源对于不同的条件,这可能证明是昂贵的,并在时间变成一团糟..
<RelativeLayout android:id="@+id/checkbox_layoyt" android:layout_ android:layout_ android:layout_alignParentLeft="true" android:layout_below="@+id/edt_layout" android:layout_marginTop="34dp" > <CheckedTextView android:id="@+id/cb_male" android:layout_ android:layout_ android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="29dp" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:checked="false" android:gravity="center" android:text=" Male" android:textColor="#000000" android:textSize="18dp" /> <CheckedTextView android:id="@+id/cb_female" android:layout_ android:layout_ android:layout_alignParentTop="true" android:layout_marginLeft="18dp" android:layout_toRightOf="@+id/cb_male" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:checked="false" android:gravity="center" android:text=" Female" android:textColor="#000000" android:textSize="18dp" /> </RelativeLayout>