@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources res = getResources();
// Bitmap from runtime creation (Not compiled)
Bitmap run_bmp = createSampleBitmap();
((ImageView)findViewById(R.id.run_org)).setImageBitmap(run_bmp);
findViewById(R.id.run_bd).setBackgroundDrawable(
new BitmapDrawable(res, run_bmp));
findViewById(R.id.run_nd).setBackgroundDrawable(
NinePatchDrawableFactory.convertBitmap(res, run_bmp, null));
// Bitmap from resource (Compiled)
Bitmap res_bmp = BitmapFactory.decodeResource(res, R.drawable.sample);
((ImageView)findViewById(R.id.res_org)).setImageBitmap(res_bmp);
findViewById(R.id.res_bd).setBackgroundDrawable(
new BitmapDrawable(res, res_bmp));
findViewById(R.id.res_nd).setBackgroundDrawable(
new NinePatchDrawable(res,
new NinePatch(res_bmp, res_bmp.getNinePatchChunk(), null)));
findViewById(R.id.res_nd_pad).setBackgroundDrawable(
NinePatchDrawableFactory.convertBitmap(res, res_bmp, null));
findViewById(R.id.res_nd_rid).setBackgroundResource(R.drawable.sample);
}
MainActivity.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:Android_NinePatchDrawableFactory
作者:
评论列表
文章目录