Skip to content

Instantly share code, notes, and snippets.

View radio_group_sample.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
@vikramkakkar
vikramkakkar / radio_group_resources.xml
Created Mar 22, 2015
Contains resources (defined colors, dimensions, and styles) for RadioGroup and RadioButtons
View radio_group_resources.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Used colors -->
<color name="fill_color_when_pressed">#84E056</color>
<color name="fill_color_when_active">#397D17</color>
<color name="stroke_color">#397D17</color>
<!-- Dimensions -->
<dimen name="stroke_width">1dp</dimen>
View radio_group_bg_last_child.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/fill_color_when_pressed">
<item>
<selector>
<item android:state_checked="true" >
<shape android:shape="rectangle">
<solid android:color="@color/fill_color_when_active" />
<corners android:topRightRadius="@dimen/corner_radius" android:bottomRightRadius="@dimen/corner_radius"/>
</shape>
</item>
View radio_group_bg_middle_child.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/fill_color_when_pressed">
<item>
<selector>
<item android:state_checked="true" >
<shape android:shape="rectangle">
<solid android:color="@color/fill_color_when_active" />
</shape>
</item>
View radio_group_bg_first_child.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/fill_color_when_pressed">
<item>
<selector>
<item android:state_checked="true" >
<shape android:shape="rectangle">
<solid android:color="@color/fill_color_when_active" />
<corners android:topLeftRadius="@dimen/corner_radius" android:bottomLeftRadius="@dimen/corner_radius"/>
</shape>
</item>
View radio_group_bg_last_child.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<solid android:color="@color/fill_color_when_pressed" />
<corners android:topRightRadius="@dimen/corner_radius" android:bottomRightRadius="@dimen/corner_radius"/>
</shape>
</item>
View radio_group_bg_middle_child.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<solid android:color="@color/fill_color_when_pressed" />
</shape>
</item>
<item android:state_checked="true" >
View radio_group_bg_first_child.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<solid android:color="@color/fill_color_when_pressed" />
<corners android:topLeftRadius="@dimen/corner_radius" android:bottomLeftRadius="@dimen/corner_radius"/>
</shape>
</item>
View radio_group_divider.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/stroke_color"/>
<size android:width="@dimen/stroke_width"/>
</shape>
View radio_group_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:color="@color/stroke_color" android:width="@dimen/stroke_width"/>
<corners android:radius="@dimen/corner_radius"/>
</shape>