<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true"> <shape android:shape="rectangle"> <!-- 填充的颜色 --> <solid android:color="@android:color/holo_blue_light" /> <!-- 设置按钮的四个角为弧形 --> <!-- android:radius 弧形的半径 --> <corners android:topLeftRadius="5dp" android:bottomLeftRadius="5dp" /> <!-- 边框 --> <stroke android:width="1dp" android:color="#ffa8abad" /> <!-- padding:Button里面的文字与Button边界的间隔 --> <padding android:bottom="5dp" android:left="10dp" android:right="10dp" android:top="5dp" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent" /> <!-- android:radius 弧形的半径 --> <corners android:topLeftRadius="5dp" android:bottomLeftRadius="5dp" /> <!-- 边框 --> <stroke android:width="1dp" android:color="#ffa8abad" /> </shape> </item> </selector>
radio右圆角:
<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true"> <shape android:shape="rectangle"> <!-- 填充的颜色 --> <solid android:color="@android:color/holo_blue_light" /> <!-- 设置按钮的四个角为弧形 --> <!-- android:radius 弧形的半径 --> <corners android:topRightRadius="5dp" android:bottomRightRadius="5dp" /> <!-- 边框 --> <stroke android:width="1dp" android:color="#ffa8abad" /> <!-- padding:Button里面的文字与Button边界的间隔 --> <padding android:bottom="5dp" android:left="10dp" android:right="10dp" android:top="5dp" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent" /> <!-- android:radius 弧形的半径 --> <corners android:topRightRadius="5dp" android:bottomRightRadius="5dp" /> <!-- 边框 --> <stroke android:width="1dp" android:color="#ffa8abad" /> </shape> </item> </selector>
radio上圆角:
<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true"> <shape android:shape="rectangle"> <!-- 填充的颜色 --> <solid android:color="@android:color/holo_blue_light" /> <!-- 设置按钮的四个角为弧形 --> <!-- android:radius 弧形的半径 --> <corners android:topRightRadius="5dp" android:topLeftRadius="5dp" /> <!-- 边框 --> <stroke android:width="1dp" android:color="#ffa8abad" /> <!-- padding:Button里面的文字与Button边界的间隔 --> <padding android:bottom="5dp" android:left="10dp" android:right="10dp" android:top="5dp" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent" /> <!-- android:radius 弧形的半径 --> <corners android:topRightRadius="5dp" android:topLeftRadius="5dp" /> <!-- 边框 --> <stroke android:width="1dp" android:color="#ffa8abad" /> </shape> </item> </selector>
其他类型圆角省略
button圆角:
<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false"> <shape android:shape="rectangle"> <!-- 填充的颜色 --> <solid android:color="@android:color/holo_blue_light" /> <!-- 设置按钮的四个角为弧形 --> <!-- android:radius 弧形的半径 --> <corners android:radius="5dp" /> <!-- padding:Button里面的文字与Button边界的间隔 --> <padding android:bottom="5dp" android:left="10dp" android:right="10dp" android:top="5dp" /> </shape> </item> <item android:state_pressed="true"> <shape android:shape="rectangle"> <solid android:color="@android:color/holo_orange_light" /> <corners android:radius="5dp" /> </shape> </item> </selector>
<RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="5dp" android:orientation="horizontal" > <RadioButton android:id="@+id/setting_map_online_rb" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="1" android:background="@drawable/common_radio_left_button" android:button="@null" android:gravity="center" android:text="@string/label_setting_map_online" /> <RadioButton android:id="@+id/setting_map_local_rb" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="1" android:background="@drawable/common_radio_right_button" android:button="@null" android:checked="true" android:gravity="center" android:text="@string/label_setting_map_local" /> </RadioGroup>