zoukankan      html  css  js  c++  java
  • Android 通过solid来定义不同边框的颜色,可以只定义一个边框的颜色

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

    在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>
  • 相关阅读:
    动手动脑之异常处理
    git一些概念
    jquery each函数使用
    数据库客户端
    plotly.js
    网站跳转汇总
    jquery 实现间隔运行
    学习 在线调试
    Robot限制字典的key大写的class
    Gerrit 相关
  • 原文地址:https://www.cnblogs.com/flyingsir/p/3963160.html
Copyright © 2011-2022 走看看