Created
December 4, 2016 22:24
-
-
Save vuhung3990/b212ec93a3977dded1ab76826cc43a22 to your computer and use it in GitHub Desktop.
custom background state on toggle radio group button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RadioGroup | |
android:orientation="horizontal" | |
android:id="@+id/radio_group" | |
android:layout_width="match_parent" | |
android:checkedButton="@+id/bt1" | |
android:layout_height="wrap_content"> | |
<RadioButton | |
android:id="@+id/bt1" | |
android:background="@drawable/toggle_bg" | |
android:layout_weight="1" | |
android:text="Left" | |
android:textColor="@color/colorPrimary" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> | |
<RadioButton | |
android:id="@+id/bt2" | |
android:background="@drawable/toggle_bg" | |
android:layout_weight="1" | |
android:textColor="@color/colorPrimary" | |
android:text="right" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> | |
</RadioGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:state_checked="true"> <!-- selected --> | |
<shape> | |
<solid android:color="@android:color/white" /> | |
<stroke android:width="3px" android:color="@android:color/holo_blue_bright" /> | |
<corners android:radius="5dp" /> | |
</shape> | |
</item> | |
<item android:state_checked="false"> <!-- default --> | |
<shape> | |
<solid android:color="@android:color/black" /> | |
<stroke android:width="1px" android:color="@android:color/darker_gray" /> | |
<corners android:radius="5dp" /> | |
</shape> | |
</item> | |
</selector> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment