android单选钮
Ⅰ 如何实现android中三个单选按钮横向排列且只能选一个
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/row_item_margin">
<TextView
android:id="@+id/tvStorageWay"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="储存方式:"/>
<RadioGroup
android:id="@+id/rgStorageWay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/tvStorageWay"
android:gravity="center_vertical"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rbPack"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="包装"/>
<RadioButton
android:id="@+id/rbBulk"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="散装"/>
<RadioButton
android:id="@+id/rbStorageWayOther"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="其它"/>
</RadioGroup>
</RelativeLayout>
Ⅱ 问一下 android radiobutton控件 控制单选按钮和文字之间的距离的问题
我觉得RadioButton原始的button如果设置为 android:button="@null“ 而用android:drowableLeft=”@drawable/radiobtn_selector“;这样显示图片的话效果会更加好,而且可以用android:drawablePading=”10dp“这个属性控制图片和字儿的距离。
希望可以帮到你。Thanks
Ⅲ android单选按钮
你要当成单选的一组的radiobutton要放在radioGROUP下,不然这个GROUP就没起作用
只有这样写,才能实现这组radiobutton是单选的效果。
Ⅳ android 用imageview实现单选功能
imageView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
v.setBackgroundResource(null); v.setBackgroundResource(R.drawable.adddoorbellon);
ImageView imageView = (ImageView) findViewById(R.id.yimenling_oneclick);
imageView.setBackgroundResource(R.drawable.akeyconfiguration);
}
});
这样试试,,最好把你的错误日志发出来