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'
相关推荐
L725622 分钟前
Android12 Wifi的连接过程梳理
android·wifi
郝晨妤33 分钟前
鸿蒙原生应用开发元服务 元服务是什么?和App的关系?(保姆级步骤)
android·ios·华为od·华为·华为云·harmonyos·鸿蒙
枫__________1 小时前
kotlin 协程 job的cancel与cancelAndJoin区别
android·开发语言·kotlin
sinat_384241092 小时前
修改Android Studio项目配置JDK路径和项目Gradle路径的GUI工具
android·java·android studio
bingbingyihao2 小时前
代码辅助工具 GPT / Cursor
android·java·gpt
少说多做3432 小时前
Android 使用 LiveData/OnCheckedChangeListener 来监听变量变化
android·java·android-studio
麻花疼不疼3 小时前
php 使用mqtt
android·开发语言·php
@解忧杂货铺4 小时前
Android和IOS的区别
android·ios·cocoa
少说多做3435 小时前
Android 网络请求(一)初识HTTP网络通信
android·网络