iis服务器助手广告
返回顶部
首页 > 资讯 > 移动开发 >Android开发手册shape属性和子属性使用说明
  • 767
分享到

Android开发手册shape属性和子属性使用说明

2024-04-02 19:04:59 767人浏览 泡泡鱼
摘要

目录?shape属性详解?子属性详解?shape属性详解 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:A

?shape属性详解

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:Android="Http://schemas.android.com/apk/res/android"
    android:innerRadius="30dp"
    android:innerRadiusRatio="2"
    android:shape="ring"
    android:thickness="2dp"
    android:thicknessRatio="3"
    android:useLevel="false">
</shape>
  • android:shape="line"  shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring) 
  • android:innerRadius  尺寸,内环的半径,仅是ring环形可用。 
  • android:innerRadiusRatio  浮点型,以环的宽度比率来表示内环的半径,比如环的宽度为50,比例为2.5,那么内环半径为20
  • android:thickness  尺寸,环的厚度 
  • android:thicknessRatio 浮点型,以环的宽度比率来表示环的厚度,和innerRadiusRatio相似
  • android:useLevel  boolean值,有时必须要加上她才有效果,写上就有效果了

?子属性详解

<corners    //定义圆角   
    android:radius="10dp"      //全部的圆角半径,例:10dp  
    android:topLeftRadius="10dp"   //左上角的圆角半径,例:10dp  
    android:topRightRadius="10dp"  //右上角的圆角半径,例:10dp  
    android:bottomLeftRadius="10dp"    //左下角的圆角半径,例:10dp  
    android:bottomRightRadius="10dp" />    //右下角的圆角半径,例:10dp  
<solid android:color="#ffff00" /> //只有一个color,设置填充颜色即可。  
<gradient  
    android:type="linear"   //共有3中渐变类型,线性渐变(默认linear)/放射渐变(radial)/扫描式渐变(sweep)  
    android:angle="0"     //渐变角度,必须为45的倍数,0为从左到右,90为从上到下 ,仅在线性渐变生效  
    android:centerX="0.2"     //渐变中心X的相当位置,范围为0~1,多应用于放射渐变  
    android:centerY="0.1"     //渐变中心Y的相当位置,范围为0~1,多应用于放射渐变  
    android:startColor="#ff0000"   //渐变开始点的颜色  
    android:centerColor="#ffff00"  //渐变中间点的颜色,在开始与结束点之间   
    android:endColor="#00ff00"    //渐变结束点的颜色  
    android:gradientRadius="10"  //渐变的半径,只有当渐变类型为radial时才能使用   
    android:useLevel="false" />  //属性通常不使用。该属性用于指定是否将该shape当成一个LevelListDrawable来使用,默认值为false。
<stroke     
    android:width="dimension"    //表示描边的宽度 
    android:color="#00ff00"   //表示描边的颜色,例绿色 
    android:dashWidth="8dp"   //虚线的宽度,值为0时便是实线,例8dp宽
    android:dashGap="1dp" />   //虚线的间隔,例间隔1dp

以上就是Android开发手册shape属性和子属性使用说明的详细内容,更多关于Android开发shape属性子属性的资料请关注编程网其它相关文章!

--结束END--

本文标题: Android开发手册shape属性和子属性使用说明

本文链接: https://www.lsjlt.com/news/151136.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作