sar*_*rts 3 android android-layout android-canvas android-activity
我有一个方形位图显示在半透明圆下面.用户可以触摸并拖动位图以定位它.我希望能够裁剪位图的任何部分.我怎样才能做到这一点?
tyc*_*czj 10
看一下支持库中的RoundedBitmapDrawable
你所要做的就是给它一个位图和角半径
RoundedBitmapDrawable img = RoundedBitmapDrawableFactory.create(getResources(),bitmap);
img.setCornerRadius(radius);
imageView.setImageDrawable(img);
Run Code Online (Sandbox Code Playgroud)
小智 7
您可以使用RoundedBitmapDrawable使您的imageview循环
这是实现roundedImageview的代码:
ImageView profilePic=(ImageView)findViewById(R.id.user_image);
//get bitmap of the image
Bitmap imageBitmap=BitmapFactory.decodeResource(getResources(), R.drawable.large_icon);
RoundedBitmapDrawable roundedBitmapDrawable=
RoundedBitmapDrawableFactory.create(getResources(), imageBitmap);
roundedBitmapDrawable.setCornerRadius(50.0f);
roundedBitmapDrawable.setAntiAlias(true);
profilePic.setImageDrawable(roundedBitmapDrawable);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8767 次 |
| 最近记录: |