Android 实现一边圆角一边直角的Button等View

参考:http://blog.csdn.net/luco2008/article/details/51014161



Android中要实现如下图的效果:

这个要在真机中才能看出效果!!

switch_button_left_checked.xml

 

view source print ? 01. "1.0" encoding="utf-8"?> 02. "http://schemas.android.com/apk/res/android" 03. android:shape="rectangle" > 04.   05. 06. "#ff304a" /> 07. 08. 09. android:width="2dp" 10. android:color="#ff304a" /> 11. 12. 13. 14. android:bottomLeftRadius="5dip" 15. android:bottomRightRadius="0dip" 16. android:topLeftRadius="5dip" 17. android:topRightRadius="0dip" /> 18.   19. 20. 21. android:bottom="5dp" 22. android:left="5dp" 23. android:right="5dp" 24. android:top="5dp" /> 25.   26. switch_button_left.xml

 

 

view source print ? 01. "1.0" encoding="utf-8"?> 02. "http://schemas.android.com/apk/res/android" 03. android:shape="rectangle" > 04.   05. 06. "#00000000" /> 07. 08. 09. android:width="2dp" 10. android:color="#ff304a" /> 11. 12. 13. 14. android:bottomLeftRadius="5dip" 15. android:bottomRightRadius="0dip" 16. android:topLeftRadius="5dip" 17. android:topRightRadius="0dip" /> 18.   19. 20. 21. android:bottom="5dp" 22. android:left="5dp" 23. android:right="5dp" 24. android:top="5dp" /> 25.   26.
switch_button_right_checked.xml

 

 

view source print ? 01. "1.0" encoding="utf-8"?> 02. "http://schemas.android.com/apk/res/android" 03. android:shape="rectangle" > 04.   05. 06. "#ff304a" /> 07. 08. 09. android:width="2dp" 10. android:color="#ff304a" /> 11. 12. 13. 14. android:bottomLeftRadius="0dip" 15. android:bottomRightRadius="5dip" 16. android:topLeftRadius="0dip" 17. android:topRightRadius="5dip" /> 18.   19. 20. 21. android:bottom="5dp" 22. android:left="5dp" 23. android:right="5dp" 24. android:top="5dp" /> 25.   26.
switch_button_right.xml

 

 

view source print ? 01. "1.0" encoding="utf-8"?> 02. "http://schemas.android.com/apk/res/android" 03. android:shape="rectangle" > 04.   05. 06. "#00000000" /> 07. 08. 09. android:width="2dp" 10. android:color="#ff304a" /> 11. 12. 13. 14. android:bottomLeftRadius="0dip" 15. android:bottomRightRadius="5dip" 16. android:topLeftRadius="0dip" 17. android:topRightRadius="5dip" /> 18.   19. 20. 21. android:bottom="5dp" 22. android:left="5dp" 23. android:right="5dp" 24. android:top="5dp" /> 25.   26.
button.xml

 

 

view source print ? 01. "1.0" encoding="utf-8"?> 02. "http://schemas.android.com/apk/res/android" 03. android:layout_width="match_parent" 04. android:layout_height="match_parent" 05. android:orientation="horizontal" 06. android:padding="10dp" > 07.   08. 09. android:id="@+id/wangdaileiBtn" 10. android:layout_width="0dp" 11. android:layout_height="40dp" 12. android:layout_weight="1" 13. android:scaleType="fitXY" 14. android:text="" 15. android:background="@drawable/switch_button_left_checked" /> 16.   17. 18. android:id="@+id/baobaoleiBtn" 19. android:layout_width="0dp" 20. android:layout_height="40dp" 21. android:layout_weight="1" 22. android:text="" 23. android:scaleType="fitXY" 24. android:background="@drawable/switch_button_right" /> 25.   26. 转载自:http://www.it165.net/pro/html/201503/36211.html


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章