您可以使用Dave Morissey的Subsampling Scale Image View作为替代标准图像视图的下拉菜单。
XML布局:在代码和禁用触摸
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:id="@+id/photo"/>
</RelativeLayout>
集图像:
photo = (SubsamplingScaleImageView) view.findViewById(R.id.photo);
photo.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
photo.setImage(ImageSource.uri(Uri.fromFile(new File("/somepath/file.png"))));
的build.gradle:
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
感谢您的回答。例如,我正在测试** 2560 x 1600 **平板电脑上的应用程序,如果我缩小它的话,背景看起来不太好。 我想使用'BitmapFactory.Options' –