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);
}
});
這樣試試,,最好把你的錯誤日誌發出來