zoukankan      html  css  js  c++  java
  • android shape的使用

    android shape的使用

    然后在布局文件里面的Button里面设置如下:

    1. <Button  
    2.    android:id="@+id/button1"  
    3.    android:layout_width="wrap_content"  
    4.    android:layout_height="wrap_content"  
    5.    android:text="Button1"  
    6.    android:background="@drawable/buttonstyle" />  




    shape用于设定形状,可以在selector,layout等里面使用,有6个子标签,各属性如下:

      1. <?xml version="1.0" encoding="utf-8"?>  
      2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
      3.       
      4.     <!-- 圆角 -->  
      5.     <corners  
      6.         android:radius="9dp"  
      7.         android:topLeftRadius="2dp"  
      8.         android:topRightRadius="2dp"  
      9.         android:bottomLeftRadius="2dp"  
      10.         android:bottomRightRadius="2dp"/><!-- 设置圆角半径 -->  
      11.       
      12.     <!-- 渐变 -->  
      13.     <gradient  
      14.         android:startColor="@android:color/white"  
      15.         android:centerColor="@android:color/black"  
      16.         android:endColor="@android:color/black"  
      17.         android:useLevel="true"  
      18.         android:angle="45"  
      19.         android:type="radial"  
      20.         android:centerX="0"  
      21.         android:centerY="0"  
      22.         android:gradientRadius="90"/>  
      23.       
      24.     <!-- 间隔 -->  
      25.     <padding  
      26.         android:left="2dp"  
      27.         android:top="2dp"  
      28.         android:right="2dp"  
      29.         android:bottom="2dp"/><!-- 各方向的间隔 -->  
      30.       
      31.     <!-- 大小 -->  
      32.     <size  
      33.         android:width="50dp"  
      34.         android:height="50dp"/><!-- 宽度和高度 -->  
      35.       
      36.     <!-- 填充 -->  
      37.     <solid  
      38.         android:color="@android:color/white"/><!-- 填充的颜色 -->  
      39.       
      40.     <!-- 描边 -->  
      41.     <stroke  
      42.         android:width="2dp"  
      43.         android:color="@android:color/black"  
      44.         android:dashWidth="1dp"  
      45.         android:dashGap="2dp"/>  
      46.       
      47. </shape> 
  • 相关阅读:
    postman的使用方法详解!最全面的教程
    免费使用的加速器
    Windows添加启动项的两种方法
    Python版本微信跳一跳,软件配置
    Inno Setup教程
    Go开发环境安装配置
    Linux下安装Phantomjs
    Python的url解析库--urlparse
    Python处理HTML转义字符
    Python使用base64编码的问题
  • 原文地址:https://www.cnblogs.com/mrray/p/6846882.html
Copyright © 2011-2022 走看看