导航:首页 > 操作系统 > 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相关的资料

热点内容
戴尔服务器怎么接电源 浏览:466
dayz好玩的国外服务器地址 浏览:521
安卓手机输入什么就没信号了 浏览:588
手机上已卸载的app怎么找回来 浏览:641
为什么点赞少的服务器就没人 浏览:128
服务器sensor干什么用的 浏览:310
抖音app互动信息在哪里 浏览:440
王者荣耀至尊宝什么时候开服务器 浏览:230
如何导出app上的教学视频 浏览:897
密封压缩机接线柱 浏览:491
phpsockethttps 浏览:672
java计算年月日 浏览:734
如何把应用加密的密码改了 浏览:542
云上钉钉加密视频 浏览:958
app推广在哪里好做 浏览:1001
编译程序后符号表位置 浏览:268
tt服务器怎么有状态 浏览:906
解压馆自己开办还是加盟 浏览:846
如何编译python可执行程序 浏览:427
51单片机中断控制教程 浏览:711