だから私の最初の質問は、あなたがラジオボタンで仕事をしたりするだろうあなたは別の問題を回避するには、仕事をするだろうと思いますより良い?
はい、RadioButton
がこの仕事に当てはまります。
それははい、それは可能であり、各ラジオボタン
の色を変更することが可能です。 android:button
のドロウアブルリソースをRadioButton
に設定するだけです。もし
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false">
<layer-list>
<item android:height="25dp" android:width="25dp">
<shape android:shape="oval">
<gradient
android:startColor="#E0FFCD"
android:endColor="#42FAA1"
android:angle="45" />
<stroke android:width="2dp"
android:color="#000000" />
</shape>
</item>
</layer-list>
</item>
<item android:state_checked="true">
<layer-list>
<item android:height="25dp" android:width="25dp">
<shape android:shape="oval">
<gradient
android:startColor="#E0FFCD"
android:endColor="#42FAA1"
android:angle="45" />
<stroke android:width="2dp"
android:color="#2d1717" />
</shape>
</item>
<item android:height="10dp" android:width="10dp"
android:gravity="center">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
</layer-list>
</item>
</selector>
:例えば:
<RadioGroup android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="5dp">
<RadioButton android:id="@+id/ware1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/Ware1"
android:button="@drawable/gradient"
android:paddingLeft="8dp" />
<RadioButton android:id="@+id/ware2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/Ware2" />
<RadioButton android:id="@+id/ware3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/Ware3" />
<RadioButton android:id="@+id/ware4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/Ware4" />
</RadioGroup>
私は最初RadioButton
のためのセレクタを作成し、このボタンの背景色がグラデーションで、あなたは一例として、これを取るとあなたを作成することができますとにかく、RadioButton
ごとにセレクタを作成する必要があり、セレクタはchecked
とunchecked
の状態がRadioButton
であるため、各ボタンのシェイプを作成するには手間がかかります。
お返事ありがとうございました:) これは私を助けました。最後に、私は 'ラジオボタンで しかしを働いています[i]を.SetCompoundDrawablesRelativeWithIntrinsicBounds(正方形、NULL、NULL、NULL);' とほんの少しの白い四角を使用し、私は必要なので、色に濃淡を設定これを動的に変更します。 –