1、shape标签简介

   shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring)  !

  设置形状:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
</shape>

2、shape的六个子标签相关属性

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" > <!--半径,左上角、右上角、左下角、右下角半径-->
<corners
android:radius="10dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
/> <!--开始颜色、中间颜色、结束颜色、
false有渐变,要使用LevelListDrawable对象,就要设置为true、
渐变角度(当angle=0时,渐变色是从左向右。 然后逆时针方向转,当angle=90时为从下往上。angle必须为45的整数倍)、
渐变类型(linear:线性,radial:放射性,sweep:扫描线式)、
渐变中心X、Y点坐标、
渐变半径(type="radial"时有效)
-->
<gradient
android:startColor="@android:color/white"
android:centerColor="@android:color/black"
android:endColor="@android:color/black"
android:useLevel="false"
android:angle="0"
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="50"/> <!--内边距 内容与边距的距离-->
<padding
android:top="10dp"
android:left="10dp"
android:bottom="10dp"
android:right="10dp"
/> <!--大小 宽高-->
<size
android:height="100dp"
android:width="100dp"/> <!--内部填充颜色-->
<solid
android:color="@color/colorPrimaryDark"/> <!--描边 颜色、宽带、虚线宽度(0为实线)、虚线间隔-->
<stroke
android:color="@color/colorPrimaryDark"
android:width="2dp"
android:dashWidth="5dp"
android:dashGap="2dp"/>
</shape>

3、四种形状使用相关的xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ClearMainActivity"
> <EditText
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="60dp"
android:gravity="center"
android:textCursorDrawable="@drawable/text_corsor"
android:drawableBottom="@drawable/editview_line"
android:textColor="@color/colorRed"
android:hint="相当于ios的placeholder"
android:textColorHint="@color/colorPrimaryDark"
android:maxLength="100"
android:background="@drawable/line_shape"
/> </LinearLayout>

  环形:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadius="80dp"
android:thickness="10dp"
android:useLevel="false"> <stroke
android:width="10dp"
android:color="#ad7997"
/>
</shape>

  其它三种

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">//rectangle,oval,line <stroke
android:width="10dp"
android:color="#ad7997"
/>
</shape>

Android之shape属性简介和使用的更多相关文章

  1. Android Activity动画属性简介

    Android Activity动画属性简介 在Android当中 设置activity的动画 需要复写 android:windowAnimationStyle这个属性 我们自定义一个动画样式来继承 ...

  2. Android之shape属性详解

    有时候 ,为了满足一些需求,我们要用到 shape 去定义 一些背景,shape 的用法 跟图片一样 ,可以给View设置 Android:background="@drawable/sha ...

  3. Android中shape属性详解

    一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用. 1.新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.x ...

  4. NDK(10)Android.mk各属性简介,Android.mk 常用模板

    参考 : http://blog.csdn.net/hudashi/article/details/7059006 本文内容: Android.mk简介, 各属性表, 常用Android.mk模板 1 ...

  5. NDK(10)Android.mk各属性简介,Android.mk 常用模板--未完

    参考 : http://blog.csdn.net/hudashi/article/details/7059006 1. Android.mk简介 Android.mk文件是GNU Makefile的 ...

  6. android中shape属性大全

    出处:http://kofi1122.blog.51cto.com/2815761/521605

  7. Android使用shape制作圆形控件及添加弹跳动画

    --------本来为作者原创,未经同意禁止转载 前言:我们在很多时候都需要在res/drawable文件夹下创建相应的xml文件来为控件添加一些样式效果,比如按钮按下时的按钮样式变化.或者指定按钮的 ...

  8. Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)

    Android XML shape 标签使用详解   一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...

  9. Android GradientDrawable(shape标签定义) 静态使用和动态使用(圆角,渐变实现)

    Android GradientDrawable使用优势: 1. 快速实现一些基本图形(线,矩形,圆,椭圆,圆环) 2. 快速实现一些圆角,渐变,阴影等效果 3. 代替图片设置为View的背景 4. ...

随机推荐

  1. Python3入门机器学习经典算法与应用✍✍✍

    Python3入门机器学习经典算法与应用 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大家看的 ...

  2. springboot整合thymeleaf手动渲染

    Thymeleaf手动渲染 为提高页面访问速度,可缓存html页面,客户端请求从缓存获取,获取不到再手动渲染 在spring4下 @Autowired ThymeleafViewResolver th ...

  3. cpu子系统(优化)

    如果业务已经在线上,你要优化,第一步如何做 首先进行服务器数据采集,和性能监测分析 一:使用cacti,nagios,zabbix 等监控工具 二:使用linux 自带的一些监控指令:vmstat,i ...

  4. 三角形的实现和盒模型、层模型、浮动模型、定位、权重、margin问题

    相邻的border会平分所占的区域,出现一个斜线, .my_triangle{ width: 10px; height: 10px; background-color: blue; border-wi ...

  5. MongoDB4.0及以上的版本安装时无法启动服务。

    问题描述:MongoDB安装过程中启动服务失败,点击忽略之后,可以安装完成.安装完成之后提示重启电脑,出现电脑蓝屏. 并且修复好电脑之后无法启动MongoDB服务. 暂时不知道原因(怀疑是MongoD ...

  6. Java中的API方法总结

    API方法总结 File file = new File(path); #创建文件对象,指向一个目录 file.exists() #判断目录或者文件是否存在 File[] files = file.l ...

  7. 【JZOJ6353】给(ca)

    description analysis 很妙的\(DP\) 设\(f[i][j]\)表示已经放了\(i\)个叶子节点.根到当前节点走了\(j\)步向左的方案数 考虑调整\(DP\)方式,钦定伸出左儿 ...

  8. C++在#include命令中,用〈 〉和“”有什么区别

    使用尖括号表示在包含文件目录中去查找(包含目录是由用户在设置环境时设置的),而不在源文件目录去查找: 使用双引号则表示首先在当前的源文件目录中查找,若未找到才到包含目录中去查找.  

  9. [JZOJ 5788] 餐馆

    思路: 考虑树形dp. 我们设\(dp[i][j][0/1]\)表示在\(i\)为根的子树中花费\(j\)单位时间,最终回到/不必回到\(i\)的最大收益. 转移三种: \(dp[x][j][0] = ...

  10. PAT甲级——A1135 Is It A Red-Black Tree 【30】

    There is a kind of balanced binary search tree named red-black tree in the data structure. It has th ...