InsetDrawable详解
来源:互联网 发布:ios蜂窝移动数据清理 编辑:程序博客网 时间:2024/06/05 10:02
InsetDrawable 表示一个drawable根据指定的距离嵌入到另外一个drawable内部。(我们看到的其实还是同一张图片,只是会空出一些边距)当控件需要的背景比实际的边框小的时候比较适合使用InsetDrawable。
很像drawable的padding属性,区别在于 padding表示drawable的内容与drawable本身的边距,insetDrawable表示两个drawable和容器之间的边距。
语法:
在drawab下自定义一个insetdrawable.xml
<?xml version="1.0" encoding="utf-8"?><inset xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/onepiece" android:insetBottom="20dp" android:insetLeft="20dp" android:insetRight="20dp" android:insetTop="20dp"></inset>在布局中引用
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.clipdrawable.MainActivity"> <ImageView android:id="@+id/clipimageview" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/insetdrawable"/></LinearLayout>显示的效果
在布局中距离左右上下都是20dp
如果没有使用insetdrawable的background属性的话,直接这样布局
<ImageView android:id="@+id/clipimageview1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/onepiece"/>那么在手机上显示的效果是
完全布满
面试题:为一个充满整个屏幕的LinearLayout布局指定背景图,是否可以让背景图不充满屏幕?请用代码描述实现过程。
解决此题,可以使用嵌入(Inset)图像资源来指定图像,然后像使用普通图像资源一样使用嵌入图像资源。
1 0
- InsetDrawable详解
- InsetDrawable详解
- insetDrawable
- InsetDrawable
- InsetDrawable 内嵌式Drawable使用详解
- Android InsetDrawable
- android drawable InsetDrawable
- Android-drawable资源-InsetDrawable
- 6.7 Android Framework - InsetDrawable
- Android Drawable之InsetDrawable
- Android Drawable之InsetDrawable
- Drawable学习之-----InsetDrawable
- Drawable子类——InsetDrawable
- Android Drawable Resource学习(八)、InsetDrawable
- Android Drawable Resource学习(八)、InsetDrawable
- insetdrawable在dialog里的用法
- Android Drawable Resource学习(八)、InsetDrawable
- Android Drawable Resource学习(八)、InsetDrawable
- JavaScript DOM对象
- uvalive4015
- GitHub开源项目地址
- HotSpot JVM
- 常见的HTTP代码错误原因及处理
- InsetDrawable详解
- 缓动弹出产品分类 【jquery】
- 《Linux C》02 文件I/O之Write操作
- Angular2入门——(2)模板语法
- php 在mac上为php添加pcntl扩展
- RabbitMQ学习之Linux下安装(一)
- C++高手必看书籍
- http://blog.jobbole.com/99911/#comment-156399
- android source camera