- 浏览: 359182 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
驭乐MJ:
你好,我卸载rar后,按命令执行安装unrar或者是p7zip ...
Ubuntu rar 乱码问题 -
郭建雄:
不错,受用了,谢谢你的分享 !
java线程中的interrupt,isInterrupt,interrupted方法 -
zuosheng:
...
用ViewFlipper实现各种切换动画 -
lxtkong-029:
原来一直不是很清楚,看来你的文章明白了,太感谢了!
java线程中的interrupt,isInterrupt,interrupted方法 -
ihopethatwell:
嗯,看到了,要在项目中添加jni
Ubuntu 10.04安装android NDK
Drawable资源是对图像的一个抽象,你可以通过getDrawable(int)得到并绘制到屏幕上。这里有几种不同类型的Drawable:
Bitmap File
基本的Bitmap图像。Android支持几种不同格式的Bitmap文件:.png(最佳)、.jpg(可接受)、.gif(不要)。
注意:Bitmap文件可能会被aapt工具进行无损图像压缩优化。例如,一个真彩色的PNG(不超过256色)可能会被转换成一个带有颜色板的8位PNG。这样做能保证图片质量一样,但减少内存占用。因此,需要了解的是放在这个文件夹下的二进制图像在编译时可能会发生变更。如果你打算以位流方式读取图像来转化成Bitmap的话,可以把它们放到res/raw中,在这里,它们不会被优化。
File Location:
res/drawable/filename.png (.png, .jpg, 或.gif)
文件名会被当作资源ID使用。
Complied Resource Datatype:
指向BitmapDrawable的资源指针。
Resource Reference:
R.drawable.filename(Java)
@[package:]drawable/filename(XML)
Example:
在res/drawable/myimage.png位置保存了一张图片,在Layout XML中可以应用这个图片到一个View上:
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/myimage" />
Shape
定义在XML中的几何形状。
File Location:
res/drawable/filename.xml
文件名将被当作资源ID使用。
Complied Resource Datatype:
指向ShapeDrawable的资源指针。
Resource Reference:
R.drawable.filename(Java)
@[package:]drawable/filename(XML)
Syntax:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape=["rectangle" | "oval" | "line" | "ring"] >
<gradient
android:angle="integer"
android:centerX="integer"
android:centerY="integer"
android:centerColor="integer"
android:endColor="color"
android:gradientRadius="integer"
android:startColor="color"
android:type=["linear" | "radial" | "sweep"]
android:usesLevel=["true" | "false"] />
<solid
android:color="color" />
<stroke
android:width="integer"
android:color="color"
android:dashWidth="integer"
android:dashGap="integer" />
<padding
android:left="integer"
android:top="integer"
android:right="integer"
android:bottom="integer" />
<corners
android:radius="integer"
android:topLeftRadius="integer"
android:topRightRadius="integer"
android:bottomLeftRadius="integer"
android:bottomRightRadius="integer" />
</shape>
Elements:
<shape>
必须。必须是根元素。
Attributes:
android:shape
Keyword。定义Shape的类型。有效的值包括:
Value
Desciption
"rectangle"
矩形。默认形状。
"oval"
椭圆。
"line"
水平直线。需要<stroke>元素定义线的宽度。
"ring"
环形。
接下来的特性只能在android:shape=”ring”时使用:
android:innerRadius
Dimension。内环的半径。
android:innerRadiusRatio
Float。以环的宽度比率来表示内环的半径。例如,如果android:innerRadiusRatio=”5”,内环半径等于环的宽度除以5。这个值可以被android:innerRadius覆盖。默认值是9。
android:thickness
Dimension。环的厚度。
android:thicknessRatio
Float。以环的宽度比率来表示环的厚度。例如,如果android:thicknessRatio=”2”,厚度就等于环的宽度除以2。这个值可以被android:thickness覆盖。默认值是3。
android:useLevel
Boolean。“true”表示可以当作LevelListDrawable使用。一般都为“false”。
<gradient>
为Shape指定渐变色。
Attributes:
android:angle
Integer。渐变色的角度值。0表示从左到右,90表示从下到上。必须是45的倍数,默认是0。
android:centerX
Float。渐变色中心的X相对位置(0-1.0)。当android:type=”linear”时无效。
android:centerY
Float。渐变色中心的Y相对位置(0-1.0)。当android:type=”linear”时无效。
android:centerColor
Color。可选的颜色,出现在start和end颜色之间。
android:endColor
Color。end颜色。
android:gradientRadius
Float。渐变色的半径。当android:type=”radial”时有效。
android:startColor
Color。start颜色。
android:type
Keyword。渐变色的样式。有效值为:
Value
Description
"linear"
线性渐变,默认值。
"radial"
环形渐变。start颜色是处于中间的颜色。
"sweep"
sweep渐变
android:useLevel
Boolean。“true”表示可以当作LevelListDrawable使用。
<solid>
填充shape的单一色。
Attributes:
android:color
Color。这个颜色会应用到shape上。
<stroke>
shape的线形。
Attributes:
android:width
Dimension。线的厚度。
android:color
Color。线的颜色。
android:dashGap
Dimension。间断线间的距离。仅在android:dashWidth设定时有效。
android:dashWidth
Dimension。间断线的大小。仅在android:dashGap设定时有效。
<padding>
内部View元素的边距。
Attributes:
android:left
Dimension。左内边距。
android:top
Dimension。上内边距。
android:right
Dimension。右内边距。
android:bottom
Dimension。下内边距。
<corners>
为shape创建圆角。当shape是一个矩形时有效。
Attributes:
android:radius
Dimension。圆角的半径。会被下面的特性覆盖。
android:topLeftRadius
Dimension。左上圆角半径。
android:topRightRadius
Dimension。右上圆角半径。
android:bottomLeftRadius
Dimension。左下圆角半径。
android:bottomRightRadius
Dimension。右下圆角半径。
Examples:
XML文件保存在res/drawable/gradient_box.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFF0000"
android:endColor="#80FF00FF"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>
Layout XML将被当作ShapeDrawable应用到一个View上:
<TextView
android:background="@drawable/gradient_box"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
发表评论
-
通过FutureTask设置超时,用于请求网络,执行任何异步超时任务
2013-10-10 15:53 0public class TestConnectTimeOu ... -
使用Eclipse调试Android Native Application
2013-07-08 21:31 0由于最近需要调试C++程序,以后都是暴力调试的,暴力调 ... -
Android新版NDK环境配置(免Cygwin)
2013-07-05 08:41 0前言:Android NDK r7及以上的版本已经集成 ... -
scroller 滚动效果
2013-04-25 14:22 0package com.testalaph; i ... -
点9 ondraw bitmap
2013-04-17 14:26 0private void init(Context ... -
点9 ondraw bitmap
2013-04-17 14:20 0点9图片ondraw画: private void ... -
通过activityGroup动态管理activity
2013-01-20 15:54 0// @Override // protected v ... -
scroller text view 滚动文字
2012-12-08 10:18 0package com.sc; import an ... -
android 截屏
2012-11-05 14:16 0//截屏2 private Bitmap jieping2 ... -
Android下Dialog及Activity屏蔽Home键详解
2011-12-13 11:53 0屏蔽其他键,重写onKeyDown Java代码 ... -
clipRect 介绍
2011-12-02 14:13 6680android的clip有以下两点疑问: Clip(剪切)的 ... -
android知识整理
2011-11-03 10:06 11. android单实例运行方 ... -
Android 使用junit测试
2011-08-05 16:18 921使用方式也非常的简单,只需要在AndroidManifest ... -
Android开发:调试工具集
2011-08-05 15:07 17931. 查看当前堆栈1) 功能:在程序中加入代码,使可以在log ... -
Android中attr自定义属性详解
2011-07-12 16:23 38648<LinearLayout xmlns:android= ... -
Drawable Mutations(Android Drawable 深入分析)
2011-07-11 11:08 1627Android's drawables对编写 ... -
检查系统是否安装某app
2011-07-11 10:45 924/** * Indicates whether th ... -
ImageView的scaletype属性
2011-07-07 13:21 817ImageView的属性android:scaleType ... -
Android UI --- 设置ProgressBar的颜色
2011-07-04 14:26 1247基本原理是在drawable目录中建立一个xml文件,描述一下 ... -
关于android的ListView优化
2011-06-24 16:58 10741.去除ListView的黑色间隔线 vie ...
相关推荐
Drawable资源管理图片处理
使用drawable资源这方面是比较容易的,笔者学习并没有花太多时间,但是却是受益匪浅。
android修改控件外观(使用drawable资源.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
主要介绍了Android 中API之Drawable资源详解及简单实例的相关资料,需要的朋友可以参考下
主要介绍了Android 将网络的Url资源转换为Drawable资源方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
最简单的使用Drawable资源的方法是,把图片放入Android工程的res\drawable目录下,编程环境会自动在R类里为此资源创建一个引用。你可以使用此引用访问该资源对象。譬如对应用程序的图标,在Java代码中可以用R....
this is a sample showing how to display drawable in android.
android中的drawable集合,包括Bitmap、shape、Layer、Transition等等
我的博客《Android动画之一:Drawable Animation》附带源码
DrawableStatesDemo 一个学习自定义Drawable以及学习DrawableState的demo #Author Wangjia55 () #效果图
android 系统通过R对象获取...获取Drawable资源: int id = context.getResources().getIdentifier(iconName, "drawable", context.getPackageName()); Drawable drawable = context.getResources().getDrawable(id);
为Android应用增加了Drawable资源之后,Android SDK会为这份资源在R清单文件中创建一个索引项:R.drawable.file.name。 接下来既可以在XML资源文件中通过@drawable/file_name访问该Drawable对象的ID,如果Java程序中...
github最新android-gif-drawable资源so; android-async-http-1.4.5.jar demo中实现了本地gif显示和网络加载gif显示
editText表情输入,直接绑定drawable里面的资源文件,方便调用
Download drawable-xhdpi.zip 图片资源
OneDrawable - 仅使用一张资源图片为 View 设置具有按下效果的背景,详细原理:http://gudong.name/2017/04/05/OneDrawable.htmlGradleAdd it in your root build.gradle at the end of repositories:allprojects...
本次我们主要讲解Android平台下的各种Drawable,这里在SDK的android.graphics.drawable包下面可以看到有各种Drawable类多达十几种,它们到底之间有什么关系和区别呢?
- "练习二:Drawable资源"(drawable、shape) - "练习三:图片浏览器" (imageview) - "练习四:AutoCompleteTextView" (autocompletetextview) - "练习五:GridView" (gridview、imageloader、自定义adapter)...