两个比较重要的xml绘制按钮selector
博客专区 > SuShine 的博客 > 博客详情
两个比较重要的xml绘制按钮selector
SuShine 发表于4年前
两个比较重要的xml绘制按钮selector
  • 发表于 4年前
  • 阅读 287
  • 收藏 2
  • 点赞 0
  • 评论 0

移动开发云端新模式探索实践 >>>   

1.圆角按钮

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">


    <item android:state_pressed="true"><shape>
            <solid android:color="#8CD6F5" />


            <corners android:radius="4dp" />


            <stroke android:width="1dp" android:color="#8CD6F5" />
        </shape></item>
    <item><shape>
            <solid android:color="#0BADEC" />


            <corners android:radius="4dp" />


            <stroke android:width="1dp" android:color="#0BADEC" />
        </shape></item>


</selector>





2.灰色方框

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >


    <stroke
        android:width="1dip"
        android:color="#88000000" />


    <corners android:radius="1dip" >
    </corners>


    <gradient
        android:centerColor="#00FFFFFF"
        android:endColor="#00FFFFFF"
        android:startColor="#00FFFFFF" />


</shape>






3.半圆按钮 比较全面
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">


    <item android:state_enabled="true" android:state_window_focused="false"><shape android:shape="rectangle">
            <stroke android:width="1px" android:color="#00000000" />


            <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />


            <gradient android:centerColor="#00A490" android:endColor="#00A490" android:startColor="#00A490" />


            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item android:state_pressed="true"><shape android:shape="rectangle">
            <stroke android:width="1px" android:color="#00000000" />


            <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />


            <gradient android:centerColor="#00A490" android:endColor="#00A490" android:startColor="#00A490" />


            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item android:state_checked="true"><shape android:shape="rectangle">
            <stroke android:width="1px" android:color="#00000000" />


            <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />


            <gradient android:centerColor="#00A490" android:endColor="#00A490" android:startColor="#00A490" />


            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item android:state_focused="true"><shape android:shape="rectangle">
            <stroke android:width="1px" android:color="#00000000" />


            <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />


            <gradient android:centerColor="#00A490" android:endColor="#00A490" android:startColor="#00A490" />


            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item><shape android:shape="rectangle">
            <stroke android:width="1px" android:color="#55000000" />


            <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />


            <gradient android:centerColor="#FFFFFF" android:endColor="#FFFFFF" android:startColor="#FFFFFF" />


            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>


</selector>








> from eoe.cn

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 118
博文 415
码字总数 87649
×
SuShine
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: