`

Android之图片处理

阅读更多

不在res/drawable/的图片可以通过BitMapBitMapFactory对象读取存储卡或手机文件系统中的图片文件。

Bitmap bm = BitmapFactory.decodeFile(image Path);

imageView.setImageBitmap(bm);

 

图片缩放

Matrix matric =new Matrix();

Matrix.postScale(new width, new height);

Bitmap resizeBmp = Bitmap.createBitmap(old bmp, 0,0,old width, old height, matrix true);

 

图片旋转

现将要旋转的图片放入暂存bitMap中,接着利用Bitmap.createBitmap()创建新的Bitmap对象,在创建新的Bitmap对象同时,搭配Matrix 对象的setRotate()动态旋转创建新的Bitmap。然后再将旋转好的Bitmap对象以新构造的方式创建新的Bitmap对象,最后放入ImageView显示即可。

 

对话框AlertDialogButton动态生成。确定按钮是PositiveButton,取消按钮是NegativeButton

New AlertDialog.Builder(className.this).setTitile()

.setIcon()

.setMessage()

.setPositiveButton(R.string.ok, new DialogInterface.onClickListener(){

   Public void onClick(DialogInterace dialoginterface, int i){

//finish();关闭窗口

}

})

.setNegativeButton(R.string.str_no, new DialogInterface.OnClickListener(){

   Public void onClick(DialogInterace dialoginterface, int i){}

})

 

隐藏式抽屉SlidingDrawer

布局有限时,使用SlidingDrawer在可视范围内放更多的组件。

 

配置可采用水平或垂直展开,在XML中必须指定使用的android:handle(委托要展开的图片)和android:content(委托要展开的Layout Content

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics