Android Drawable - Inset Drawable使用详解(附图)
来源:互联网 发布:人工智能的产品有哪些 编辑:程序博客网 时间:2024/06/05 10:53
一个可以让Drawable内嵌到自己View当中, 并且可以设置Drawable到View边缘之间的边距, 当然LayerDrawable也可以办到
资源放置位置:
Eclipse/AS: res/drawable/filename.xml
引用用法:
In Java: R.drawable.filename
In XML: @drawable/filename
语法:
<?xml version="1.0" encoding="utf-8"?><inset xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/drawable_resource" android:insetTop="dimension" android:insetRight="dimension" android:insetBottom="dimension" android:insetLeft="dimension" />
- 首个标签必须是inset;
- android:drawable: Drawable资源引用;
- android:insetTop: Drawable距离View顶部边缘的距离;
- android:insetRight: Drawable距离View右边边缘的距离;
- android:insetBottom: Drawable距离View底部边缘的距离;
- android:insetLeft: Drawable距离View左边边缘的距离;
example:
布局XML代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--Inset Drawable--> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/inset_drawable" android:gravity="center" android:text="Inset Drawable" android:textAllCaps="false"/></LinearLayout>
inset_drawable.xml
<?xml version="1.0" encoding="utf-8"?><inset xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/img" android:insetBottom="20dip" android:insetLeft="20dip" android:insetRight="20dip" android:insetTop="20dip"/>
img.xml(shape图片)
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00ffff"/></shape>
0 0
- Android Drawable - Inset Drawable使用详解(附图)
- Android Drawable - Shape Drawable使用详解(附图)
- Android Drawable - Bitmap Drawable使用详解(附图)
- Android Drawable - Layer Drawable使用详解(附图)
- Android Drawable - State List Drawable使用详解(附图)
- Android Drawable - Level List Drawable使用详解(附图)
- Android Drawable - Transition Drawable使用详解(附图)
- Android Drawable - Scale Drawable使用详解(附图)
- Android Drawable - Clip Drawable使用详解(附图)
- Android Drawable - Shape Drawable使用详解(附图)
- Inset Drawable
- Android Drawable Resources系列7:<inset>
- Android Drawable Resources 之 Shape Drawable 使用详解
- Drawable基础知识总结----drawable标签LevelList、inset、scale、clip的使用
- Android:Drawable资源详解
- Android-Drawable详解【占坑中】
- Android Drawable详解
- android的Drawable详解
- 类的其他特性
- iOS教程:如何仿一款“账本”上架app(一)
- 学习篇---幸运转盘
- Spark Streaming源码解读之JobScheduler内幕实现和深度思考
- Hust oj 2084(大数)
- Android Drawable - Inset Drawable使用详解(附图)
- SQL Server error '80040e14'的处理
- 必须跟你说点事《TCP 三次握手》
- MySQL 5.6内存占用过高解决方案【总结】
- Codeforces 193D Two Segments (线段树)
- How HashTable(HashMap) works and preformance
- 【心得】要细心,思维要严谨,养成良好的代码习惯
- 有关网络编程的一些面试
- vim如何设置缩进以及行号