其实画圆角,半圆角之类的按钮从技术上来讲并没有什么难度,之所以写这个问题是因为在项目很多地方都要用到,所以对此做一个总结。
在项目中建立bg_button_friends.xml文件放在drawable文件夹下面。
xmlns:android=”http://schemas.android.com/apk/res/android”
android:shape=”rectangle”>
–>
android:bottomLeftRadius=”8dip”
/>
里面有很多属性:
填充的颜色
线的宽度,颜色
设置按钮四个角为圆角
android:topLeftRadius=”8dip”左上角圆形半径
android:topRightRadius=”8dip”右上角圆形半径
android:bottomRightRadius=”8dip”右下角圆形半径
android:bottomLeftRadius=”8dip”左下角圆形半径
android:shape=”line”画线
android:dashWidth=”2dp” android:dashGap=”3dp” />
android:startColor=”#ff8c00″
android:endColor=”#FFFFFF”
android:angle=”270″ />
android:startColor和android:endColor分别为起始和结束颜色,