Java 如何使位图(在src中设置)压缩?
我编写了一个通用自定义ImageView,其中有部分代码:Java 如何使位图(在src中设置)压缩?,java,android,eclipse,android-studio,bitmap,Java,Android,Eclipse,Android Studio,Bitmap,我编写了一个通用自定义ImageView,其中有部分代码: public class AvatarImageView extends ImageView { @Override protected void onDraw(Canvas canvas) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); // I want to make this bitmap compress } 然后我可以像这样使用这个自定义图像视
public class AvatarImageView extends ImageView {
@Override
protected void onDraw(Canvas canvas) {
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
// I want to make this bitmap compress
}
然后我可以像这样使用这个自定义图像视图:
<CustomerView.AvatarImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/avatar"
/>
它需要提供一个resId。但是我想重用这个自定义的ImageView,所以我不能提供特定的id有什么好的解决方法吗?
非常感谢您的帮助。谢谢
BitmapFactory.decodeResource(res, resId, options);