android的drawable资源
1.android中可以通过xml文件配置资源,比如字符串啦,整数拉。浮点数等等,当然也可以配置图片资源和选择器,下面我们就看看几种图片资源的配置。
@1矩形方框,带渐变色的配置代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <!--设置黑色边框-->
<stroke android:color="#000" android:width="2px"/>
<!--设置渐变-->
<gradient
android:angle="360"
android:endColor="#c0c0c0"
android:startColor="#fcd209"/> <!--设置边距-->
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp"/> </shape>
看看效果:

@2带圆角的矩形框
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> <!--设置透明背景色-->
<!---->
<solid
android:color="#87ceeb"/>
<stroke android:width="2px"
android:color="#000"/> <!--设置四个圆角半径-->
<corners
android:topRightRadius="10px"
android:bottomRightRadius="10px"
android:topLeftRadius="10px"
android:bottomLeftRadius="10px"
/>
<padding
android:left="5dp"
android:right="5dp"
android:top="5dp"
android:bottom="5dp"/> </shape>
看看效果:

@3椭圆形drawable代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#88005621"/> <stroke
android:color="#000000"
android:width="2px"/> <corners
android:radius="20dp"/> </shape>
看看效果:

@4环形资源代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.market.shapedrawable.MainActivity"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="100dp"
android:background="@drawable/ring"
android:text="Hello World!" />
</RelativeLayout>
看看效果:

@5原点或实心圆资源代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#ff2236"/> <size
android:width="10dp"
android:height="10dp"
/>
</shape>
看看效果:

android的drawable资源的更多相关文章
- Android 程序drawable资源保存到data目录
今天做了个小功能,就是把我们程序Drawable里面的图片保存到data目录下面,然后另外一个程序需要读取data目录里面保存的图片.涉及了data目录读写.这功能看上去挺简单,不过实际做的时候还是遇 ...
- [转]android中drawable资源的解释及例子
原文链接: http://blog.csdn.net/wode_dream/article/details/38584693 文章中的内容参考Dev Guide中的Drawable R ...
- Android使用Drawable资源之使用ClipDrawable资源 实现进入条
以前我自定义的进度条(就是咱们现在工程中用的)是从android的源码中扒出来的一个XML,然后把里面的图片给替换了.一直不知道它的具体原理是什么. 今天得空研究了一下,发现它的原理其实就是用的and ...
- Android 寻找Drawable资源的流程
寻找设备对应Drawable资源时,会先在设备对象dpi的drawable文件夹下寻找,如果没找到,会上溯到更高一级dpi文件夹下寻找,上溯最高两级.如果还是没有找到,会寻找noDensity文件夹下 ...
- Android Drawable资源
Android实现应用d动画效果:比如App第一次打开的开始动画等 有两种:GIF动画和代码实现. 第一种:借助于Gif制作工具软件实现.一般是和第三方开源的GifView(https://githu ...
- Android中的Drawable资源
在Android应用中,常常会用到Drawable资源,比如图片资源等,在Android开发中我们是用Drawable类来Drawable类型资源的. Drawable资源一般存储在应用程序目录的\r ...
- android中常见的Drawable资源有哪些?
Drawable资源是安卓应用中最常见的一种资源,比如图片等,因此,对于初学者而言,必须掌握drawable资源相关应用. 今天在网上刚好看到了一篇介绍android Drawable资源的文章,分享 ...
- android 各种xml资源的引用方式
更多资源类型 本页定义了其它一些具体的资源类型,包括: Bool 存放布尔值的XML资源. Color 存放颜色值的XML资源(十六进制颜色). Dimension 存放数量值的XML资源(带计量单位 ...
- Android之drawable state各个属性详解
android:drawable 放一个drawable资源android:state_pressed 是否按下,如一个按钮触摸或者点击.android:state_focused 是否取得焦点,比如 ...
随机推荐
- 关于BSTR和SysStringLen方法的简单研究
英文的我编不下去了,所以还是先写个中文的吧, 之前遇到了SysStringLen求Bstr长度不正确的问题,试验了几次都不行的情况下我觉得可能是这个方法的bug,所以就没管. 大概的情况是这样: in ...
- 根据优先关系矩阵使用逐次加一发构造优先函数(Java)
若已知运算符之间的优先关系,可按如下步骤构造优先函数: 1.对每个运算符a(包括#在内)令f(a)=g(a)=1 2.如果a⋗b且f(a)<=g(b)令f(a)=g(b)+1 3.如果a⋖b且f ...
- BM25和Lucene Default Similarity比较 (原文标题:BM25 vs Lucene Default Similarity)
原文链接: https://www.elastic.co/blog/found-bm-vs-lucene-default-similarity 原文 By Konrad Beiske 翻译 By 高家 ...
- Vector的浅析
Vector 可实现自动增长的对象数组.java.util.vector 提供了向量类(vector)以实现类似动态数组的功能.在Java语言中没有指针的概念,但如果正确灵活地使用指针又确实可以大大提 ...
- 设计模式浅谈----策略模式(c#及java实现)
一.何为策略模式 策略模式是行为型模式的一种,主要用于需要使用不同的算法来处理不同的数据对象时使用,是一种可以在运行时选择算法的设计模式.也称为政策模式. 主要解决:在有多种算法相似的情况下,使用 i ...
- 接口测试-jmeter
一.jmeter下载安装 1)安装jdk(见博文<windows上安装jdk>) 2)在jmeter官网下载 http://jmeter.apache.org/download_jmet ...
- UILabel图文混排显示图片和文字
//传入文字 自动图片放在左边文字紧接着后排排布 -(void)setAttrDetailLabelWithTitle:(NSString *)title { NSMutableAttributedS ...
- Nodejs基础:stream模块入门介绍与使用
本文摘录自<Nodejs学习笔记>,更多章节及更新,请访问 github主页地址.欢迎加群交流,群号 197339705. 模块概览 nodejs的核心模块,基本上都是stream的的实例 ...
- linux开发常用命令
最近经常查看服务器上的log文件,有时log文件太大查起来很不方便,看了看网上说可以部分查询,就先记录一下吧 Linux中查看部分文件内容命令head,tail,sed的用法: Linux中的查看文件 ...
- SimpleDateFormat使用和线程安全问题
SimpleDateFormat 是一个以国别敏感的方式格式化和分析数据的具体类. 它允许格式化 (date -> text).语法分析 (text -> date)和标准化. Simpl ...