Android之shape属性简介和使用
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属性简介和使用的更多相关文章
- Android Activity动画属性简介
Android Activity动画属性简介 在Android当中 设置activity的动画 需要复写 android:windowAnimationStyle这个属性 我们自定义一个动画样式来继承 ...
- Android之shape属性详解
有时候 ,为了满足一些需求,我们要用到 shape 去定义 一些背景,shape 的用法 跟图片一样 ,可以给View设置 Android:background="@drawable/sha ...
- Android中shape属性详解
一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用. 1.新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.x ...
- NDK(10)Android.mk各属性简介,Android.mk 常用模板
参考 : http://blog.csdn.net/hudashi/article/details/7059006 本文内容: Android.mk简介, 各属性表, 常用Android.mk模板 1 ...
- NDK(10)Android.mk各属性简介,Android.mk 常用模板--未完
参考 : http://blog.csdn.net/hudashi/article/details/7059006 1. Android.mk简介 Android.mk文件是GNU Makefile的 ...
- android中shape属性大全
出处:http://kofi1122.blog.51cto.com/2815761/521605
- Android使用shape制作圆形控件及添加弹跳动画
--------本来为作者原创,未经同意禁止转载 前言:我们在很多时候都需要在res/drawable文件夹下创建相应的xml文件来为控件添加一些样式效果,比如按钮按下时的按钮样式变化.或者指定按钮的 ...
- Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)
Android XML shape 标签使用详解 一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...
- Android GradientDrawable(shape标签定义) 静态使用和动态使用(圆角,渐变实现)
Android GradientDrawable使用优势: 1. 快速实现一些基本图形(线,矩形,圆,椭圆,圆环) 2. 快速实现一些圆角,渐变,阴影等效果 3. 代替图片设置为View的背景 4. ...
随机推荐
- 14-Ubuntu-文件和目录命令-查看目录内容-ls-1
1.终端使用技巧 (1)tab键自动补全 (2)按上/下光标键查看使用过的命令 (3)退出当前命令,Ctrl C (4)缩小--Ctrl - ;放大--Ctrl shift + 2.ls 命令--查看 ...
- Django ORM 之基于对象、双下划线查询
返回ORM目录 Django ORM 内容目录: 一. 基于对象的表查询 二. 基于双下划线的查询 三. 聚合查询 aggregate 四. 分组查询 annotate 一. 基于对象的表查询 1.正 ...
- MySQL基础知识 数据库 数据表
1.数据库结构 库 表 数据 2. sql(structured query language)结构化查询语言 管理数据库 管理表 管理数据 3.数据库 增删改查 增 create database ...
- npm run server报错
从git上clone的vue项目npm install后npm run server报错 $ npm run dev > lufei@1.0.0 dev E:\pythonProject\luf ...
- js单线程
由于js是运行在单线程上的,所有浏览器单独开启一个线程来处理事件消息的轮询,避免阻塞js的执行.
- t检验中的t值和p值是什么关系_t检验和p值的关系
t检验中的t值和p值是什么关系_t检验和p值的关系 t检验中通过样本均值 总体均值 样本标准差 样本量 可以计算出一个t值,这个t值和p值有什么关系? 根据界值表又会查出一个数,这个数和t值比较,得出 ...
- day 53 Django基础二之URL路由系统
Django基础二之URL路由系统 本节目录 一 URL配置 二 正则表达式详解 三 分组命名匹配 四 命名URL(别名)和URL反向解析 五 命名空间模式 一 URL配置 Django 1.11 ...
- 在任务管理中显示进程ID号
- mui 上拉加载 实现分页加载功能
mui 上拉加载 实现分页加载功能,效果图: 分页功能(上拉加载): 1.引入需要的css.js文件 <link href="static/css/mui.css" rel= ...
- Django高级实战 开发企业级问答网站✍✍✍
Django高级实战 开发企业级问答网站 1. 创建项目与app 创建项目 django-admin startproject firstsite 创建app python manage.py sta ...