导航:首页 > 操作系统 > androidclipdrawable

androidclipdrawable

发布时间:2025-07-21 07:43:37

android里面layer-list中的inset和clip到底有什么作用

Inset Drawable:用于通过指定的间距把图片插入到XML中,它在View需要比自身小的背景时常用。有些像padding的作用。例子:
第一步:drawable文件中建立inset_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<inset
xmlns:android="http://schemas。android。com/apk/res/android"
android:drawable="@drawable/photo2"
android:insetTop="100dp"
android:insetRight="100dp"
android:insetBottom="200dp"
android:insetLeft="100dp" />

第二部,在xml中引用
<LinearLayout xmlns:android="http://schemas。android。com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/inset_drawable">

Clip Drawable:可以剪载图片显示,例如,可以通过它来做进度度。你可以选择是从水平或垂直方向剪载。其中的gravity设置从整个部件的哪里开始。例子:
第一步,在drawable文件中建立:clip_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas。android。com/apk/res/android"
android:drawable="@drawable/test_img"
android:clipOrientation="horizontal"
android:gravity="left" />
第二步,在ImageView中引用:
<LinearLayout xmlns:android="http://schemas。android。com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ImageView
android:id="@+id/clipimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/clip_drawable"/>
</LinearLayout>
Dev Guide中在ImageView中设置的是android:background="@drawable/clip_drawable",但是我使用background的时,会在程序中报空指针的错误。
最后,使用程序控制:
ImageView imageView=(ImageView)findViewById(R.id.clipimage);
ClipDrawable clipDrawable=(ClipDrawable)imageView.getDrawable();
clipDrawable.setLevel(5000);
level的值为0到10000 。当值为10000时图全部显示。

阅读全文

与androidclipdrawable相关的资料

热点内容
解压小手工A4纸 浏览:975
钢筋加密区是几倍 浏览:664
编译程序代码软件 浏览:800
怎么恢复加密的东西 浏览:981
程序员卖茶 浏览:697
后端程序员英文 浏览:360
滴滴程序员平均月薪 浏览:591
如何使用ftp命令 浏览:787
小书亭下载的文件在哪手机文件夹 浏览:176
交叉编译器编译单个c文件 浏览:513
代理服务器地址列表吧 浏览:930
java列出所有文件 浏览:868
压缩包看图软件 浏览:191
sqlite在android中的应用 浏览:661
一本通pdf 浏览:916
2021免费的编程软件 浏览:126
项目编译后浏览器不对应刷新 浏览:567
三星升级android60 浏览:297
粘土的压缩模量 浏览:120
美国程序员生活 浏览:223