Android 超大图预览 防止OOM
package com.blink.analysis.act;
import android.widget.ImageView;
import androidx.recyclerview.widget.GridLayoutManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.blink.analysis.R;
import com.blink.analysis.adapter.PreviewAdapter;
import com.blink.analysis.databinding.ActivityBigImageBinding;
import com.blink.analysis.databinding.ActivityPreviewImageBinding;
import com.blink.base.utils.ImagesUtils;
import com.blink.golfpal.base.BindingBaseActivity;
import com.blink.golfpal.base.RoutePathCommon;
import com.davemorrissey.labs.subscaleview.ImageSource;
import java.util.ArrayList;
@Route(path = RoutePathCommon.Analysis.BIG_IMAGE)
public class BigImageActivity extends BindingBaseActivity<ActivityBigImageBinding> {
@Override
protected int getContentViewLayoutID() {
return R.layout.activity_big_image;
}
@Override
protected void initViewsAndEvents() {
initTitle("大图片预览");
// mBinding.imageView.setImage(ImageSource.resource(R.mipmap.ic_scan_image_front_left));
// mBinding.imageView.setImage(ImageSource.asset("map.png"));
// mBinding.imageView.setImage(ImageSource.uri("/sdcard/DCIM/map.JPG"));
// mBinding.imageView.setImage(ImageSource.bitmap(bitmap));
}
}
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingDefaultResource">
<data>
</data>
<LinearLayout
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include
android:id="@+id/include_title"
layout="@layout/layout_common_title_bar_white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</layout>
api 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
其他
implementation 'com.github.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
原文地址:https://blog.csdn.net/qq_28934205/article/details/143901525
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!