zoukankan      html  css  js  c++  java
  • Android 按钮设置边框实例

    以下一Button标签为例:

    这里就联系到标签<shape>,设置背景样式、边框、渐变、圆角等,各种效果的使用方法见如下代码

    drawable文件夹新建一个buttonstyle.xml,内容如下

    1 <?xml version="1.0" encoding="utf-8"?>  
    2 <shape xmlns:android="http://schemas.android.com/apk/res/android">  
    3     <gradient android:startColor="#c0000000"  android:endColor="#c0000000" android:angle="90" /><!--背景颜色渐变 angle为渐变角度-->  
    4     <solid android:color="#00ffffff" /><!-- 背景填充颜色 -->  
    5     <stroke android:width="3dp" android:color="#ff000000" /><!-- 描边,边框宽度、颜色 -->  
    6     <corners android:radius="10dp" /><!-- 边角圆弧的半径 -->  
    7     <padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp" /><!-- 四周留出来的空白 -->  
    8 </shape>  

    然后在button里面引用如下:

    <Button    
       android:id="@+id/button"    
       android:layout_width="wrap_content"    
       android:layout_height="wrap_content"    
       android:text="按钮"    
       android:background="@drawable/buttonstyle" /> 

     引用:http://blog.csdn.net/mj19910923/article/details/8633255

  • 相关阅读:
    Day2 while 循环,格式化输出,运算符,字符串编码
    Day 1 变量,基础数据类型与条件语句
    关于字符的一些看法
    正则的全局问题
    模块——js功能(倒计时,幻灯)
    垂直居中
    不确定宽度元素居中
    css3媒体查询
    less的预处理
    手机幻灯
  • 原文地址:https://www.cnblogs.com/jxyZ/p/3964279.html
Copyright © 2011-2022 走看看