|
mjava 代码 :
import android.graphics.*;
import android.graphics.drawable.*;
setNine(android.widget.LinearLayout view, String path){
Bitmap bitmap= BitmapFactory.decodeFile(path);
NinePatchDrawable nineDrawable= null;
byte[] chunk = bitmap.getNinePatchChunk(); // 如果.9.png没有经过第一步,那么chunk就是null
if(NinePatch.isNinePatchChunk(chunk)) {
NinePatchDrawable patchy = new NinePatchDrawable(bitmap, chunk, new Rect(), null);
view.setBackground(patchy);
}
}
调用方法:
gvs(st_vW, Card.8, bubble)
s path = "/storage/emulated/0/1/images/skin_aio_friend_bubble_nor.9.png"
call(null, "mjava", "ui.setNine", bubble, path)
// 注意:Card.8 是线性布局控件
// path 必须是绝对路径。
|
|