android clip
来源:互联网 发布:淘宝店与客人聊天 编辑:程序博客网 时间:2024/05/16 06:20
ClipDrawable 是对一个Drawable进行剪切操作,可以控制这个drawable的剪切区域,以及相相对于容器的对齐方式,android中的进度条就是使用一个ClipDrawable实现效果的,它根据level的属性值,决定剪切区域的大小。
需要注意的是ClipDrawable是根据level的大小控制图片剪切操作的,官方文档的note中提到:The drawable is clipped completely and not visible when the level is 0 and fully revealed when the level is 10,000。也就是level的大小从0到10000,level为0时完全不显示,为10000时完全显示。是用Drawable提供的setLevel(int level)方法来设置剪切区域。
- 文件位置:
res/drawable/filename.xml
文件名即资源ID- 编译资源类型:
- 指向
ClipDrawable
的指针 - 资源引用:
- In Java:
R.drawable.filename
In XML:@[package:]drawable/filename
- 语法
<?xml version="1.0" encoding="utf-8"?><clip xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/drawable_resource" android:clipOrientation=["horizontal" | "vertical"] android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" | "fill_vertical" | "center_horizontal" | "fill_horizontal" | "center" | "fill" | "clip_vertical" | "clip_horizontal"] />
- 元素:
- 示例:
- 文件保存在
res/drawable/clip.xml
:<?xml version="1.0" encoding="utf-8"?><clip xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/android" android:clipOrientation="horizontal" android:gravity="left" />
在layout xml文件中使用:
<ImageView android:id="@+id/image" android:background="@drawable/clip" android:layout_height="wrap_content" android:layout_width="wrap_content" />
下面的代码或得到clipDrawable对象,并且增加裁剪区逐步显示图片:
ImageView imageview = (ImageView) findViewById(R.id.image);ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();drawable.setLevel(drawable.getLevel() + 1000);
逐步增加裁剪区域,逐步显示图片。这个裁剪区是7000:
注意:默认的level是0,表示全部裁剪掉了,图片不可见,但是显示的时候,依然会占据位置。当level是10,000,图片相当于没裁剪,完全可见。
- 参考:
ClipDrawable
转自:http://blog.csdn.net/lonelyroamer/article/details/8244777
- android clip
- regin,clip Android
- regin,clip Android
- clip
- clip
- android中clip的使用
- clip.xml资源文件---android
- Android canvas clip 参数解释
- Android Outline,Shadow和Clip
- android中clip的使用
- Android Canvas Region.Op中的Clip方式
- Android Canvas Region.Op中的Clip方式
- Android Drawable Resources系列8:<clip>
- android中使用Clip复制粘贴
- Android Clip用法——自定义进度条
- Clip Drawable “坑爹”的android doc 源文档
- android 使用clip.xml 作为drawable 作成进度条图片效果
- android之通过clip自定义progress进度条样式
- 3分钟写出来的Jquery版checkbox全选反选功能
- NSInvocation的使用
- C语言的那些事——scanf()和gets()在字符串中出现空格时的区别比较
- 智能指针(Smart Pointer)
- JPA的主键产生策略
- android clip
- Centos6.3中安装GlassFish3.1.2.2
- 深入理解硬盘的Linux分区
- C# Label显示多行文本及换行(WinForm/WebForm)
- YARN概述
- 适配iOS7之—UITableView和UISearchBar
- java String类
- javascript内存管理和垃圾回收
- java编码(四)编码错误例子