码迷,mamicode.com
首页 > 移动开发 > 详细

Android 通过solid来定义不同边框的颜色,可以只定义一个边框的颜色

时间:2014-09-09 19:56:59      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   color   io   ar   文件   div   

以下是设置按钮的右边框和底边框颜色为红色,边框大小为3dp,如下图:

bubuko.com,布布扣

在drawable新建一个 btnstyle.xml的文件,内容如下:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <!-- 连框颜色值 -->
    <item >
        <shape >
            <solid android:color="#ff0000"/><!-- 边框 red -->
        </shape>
    </item>
    <!-- 主体背景颜色值 -->
    <item android:bottom="3dp" android:right="3dp"><!-- 设置画几个边 -->
        <shape >
            <solid android:color="#009900"/><!-- 主体 green -->
            <padding android:bottom="10dp"
                android:left="10dp"
                android:right="10dp" 
                android:top="10dp"
                />
        </shape>
    </item>

</layer-list>

 

引用  

 android:background="@drawable/btnstyle"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/btnstyle"
        android:text="Button" />

</RelativeLayout>

 

Android 通过solid来定义不同边框的颜色,可以只定义一个边框的颜色

标签:android   style   blog   http   color   io   ar   文件   div   

原文地址:http://www.cnblogs.com/flyingsir/p/3963160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!