范围
图像位图必须显示为imageView.setImageBitmap(bitmap),并缩放以适应UI。这可以通过以下方式完成:
bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true);
xml's ImageView attributes such as
android:layout_width="newWidth" android:layout_height="newHeight" android:adjustViewBounds="true" android:scaleType="fitCenter"
问题
性能方面哪种方式更好?我更喜欢使用xml,因为这是UI特定的问题,并且我喜欢使用xml来定义UI。此外,我们在dp中设置宽度/高度值,这意味着我们可以在不同屏幕上拥有相同的UI。 谢谢!