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. ...
随机推荐
- Spring AOP源码分析(三):基于JDK动态代理和CGLIB创建代理对象的实现原理
AOP代理对象的创建 AOP相关的代理对象的创建主要在applyBeanPostProcessorsBeforeInstantiation方法实现: protected Object applyBea ...
- 解决在python中进行CGI编程时无法响应的问题
问题:我期望的效果是,后端解析脚本后,将结果返回给我,而不是将代码返回给我或者是让我下载文件. 参考地址:https://blog.csdn.net/C_chuxin/article/details/ ...
- 解决WIN8输入法的问题,Ctrl+空格,Ctrl+Shift,切换问题
在WIN8中,我们曾经熟悉的的Ctrl+空格和Ctrl+Shift消失了,取而导致的是WIN+空格. 在这里先简单解释一下WIN8的输入法结构: 在WIN7以前的输入法中,输入法采用了平行目录的结构, ...
- D3.js坐标轴的绘制方法、添加坐标轴的刻度和各比例尺的坐标轴(V3版本)
坐标轴(Axis) 坐标轴(Axis)在很多图表中都可见到,例如柱形图.折线图.散点图等.坐标轴由一组线段和文字组成,坐标轴上的点由一个坐标值确定.但是,如果使用SVG的直线和文字一笔一画的绘制坐 ...
- redis集群的学习(一)
redis配置文件详解 redis默认是不作为守护进程来运行的,你可以把这个设置为yes,让它作为守护进程来运行 注意,当作为守护进程的时候,redis 会把进程ID 写到/var/run/redis ...
- 用Jquery写返回顶部代码
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>jq ...
- ctrl+shift+k取消
因为typora软件和搜狗输入法软件的快捷键重合了,ctrl+shift+k在typora中是代码块的快捷键,而在搜狗输入法中是软键盘快捷键,显然软键盘不重要. 搜狗输入法的ctrl+shift+k取 ...
- 关于TMDS
https://en.wikipedia.org/wiki/Transition-minimized_differential_signaling TMDS,Transition Minimized ...
- cocos2D-X LUA 非常简单的一个贪吃蛇案例
--[[ 贪吃蛇 ]] local RetroSnaker = class("RetroSnaker", function() return cc.Layer:create(); ...
- [转]MySQL InnoDB引擎索引长度受限怎么办
mysql> CREATE TABLE `tb` (-> `a` varchar(255) DEFAULT NULL,-> `b` varchar(255) DEFAULT NULL ...