各种drawable 小的例子,
开源中国地址:https://git.oschina.net/lyxs916/drawable-test.git
bitmap
bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="false"
android:dither="true"
android:src="@mipmap/ic_launcher"
android:tileMode="mirror"
bitmap
clip
clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="horizontal"
android:drawable="@mipmap/y"
clip
inset
inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@color/colorAccent"
android:inset="20dp"
inset
layer-list
layer-list xmlns:android="http://schemas.android.com/apk/res/android"item
android:width="150dp"
android:height="150dp"bitmap android:src="@mipmap/a" item
item
android:width="80dp"
android:height="80dp"
android:left="30dp"
android:top="50dp"bitmap android:src="@mipmap/y" item
item
android:width="50dp"
android:height="50dp"
android:left="40dp"
android:top="60dp"bitmap android:src="@mipmap/a" item
layer-list
level-list
level-list xmlns:android="http://schemas.android.com/apk/res/android"
item
android:drawable="@mipmap/a"
android:maxLevel="10"
android:minLevel="5"
item
android:drawable="@mipmap/y"
android:maxLevel="15"
android:minLevel="11"
item
android:drawable="@mipmap/ic_launcher"
android:maxLevel="4"
android:minLevel="0" level-list
selector
selector xmlns:android="http://schemas.android.com/apk/res/android"
item android:drawable="@mipmap/a" android:state_focused="true"
item android:drawable="@mipmap/y" android:state_selected="true"
item android:drawable="@mipmap/g" android:state_pressed="true"
item android:drawable="@mipmap/ic_launcher" selector
transition
transition xmlns:android="http://schemas.android.com/apk/res/android"item android:drawable="@mipmap/a" item android:drawable="@mipmap/y" transition
/**
* 类说明:绘制圆形的drawable
* Created by 阳 2017/3/12 17:00
*/
public class extends private mPaintprivate mBitmapprivate int mWidth
public thismBitmap mPaint new //着色器
new mBitmapCLAMPCLAMPmPainttruemPaintmWidth minmBitmapmBitmap
@Override
public void
mWidth 2mWidth 2mWidth 2mPaint
@Override
public void int //设置画笔的透明度
mPaint
@Override
public void //设置颜色
mPaint
@Override
public int //设置不透明度
return TRANSLUCENT
@Override
public int //返回drawable实际宽
return mWidth
@Override
public int //返回drawable实际高
return mWidth
/**
* 类说明:绘制圆角的drawable
* Created by 阳 2017/3/12 17:00
*/
public class extends private mPaintprivate mBitmapprivate mRectFprivate int mRound
/**
* @param bitmap 位图
* @param round 圆角的值
*/
public int thismBitmap mPaint new //着色器
new mBitmapCLAMPCLAMPmPainttruemPaintmRound abs
@Override
public void mRectFmRoundmRoundmPaint
@Override
public void int int int int mRectF new
@Override
public void int //设置画笔的透明度
mPaint
@Override
public void //设置颜色
mPaint
@Override
public int //设置不透明度
return TRANSLUCENT
@Override
public int //返回 图片 实际宽
return mBitmap
@Override
public int //返回 图片 实际高
return mBitmap