Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行时图像比率检查(性能问题)-android_Android_Android Imageview - Fatal编程技术网

运行时图像比率检查(性能问题)-android

运行时图像比率检查(性能问题)-android,android,android-imageview,Android,Android Imageview,我有一个图像选择器应用程序,可以从图库中选择图像。如果图像没有特定的宽高比,我会在图像顶部显示一个小警告符号 在我的XML视图文件中,我有两个ImageView视图。详情如下: view.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_co

我有一个图像选择器应用程序,可以从图库中选择图像。如果图像没有特定的宽高比,我会在图像顶部显示一个小警告符号

在我的XML视图文件中,我有两个
ImageView
视图。详情如下:

view.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="10dp" >

 <ImageView
        android:id="@+id/imgQueue"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:scaleType="centerCrop" />

<ImageView
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:id="@+id/wrongimagesign"
        android:src="@drawable/error"
        android:layout_alignTop="@+id/imgQueue"
        android:layout_alignRight="@+id/imgQueue"
        android:layout_alignEnd="@+id/imgQueue"
        android:visibility="invisible"/>

</RelativeLayout>

问题是,因为我正在加载位图,所以性能非常慢(加载图像和显示警告标志所需的时间太长)。有没有提高性能的方法。

您所说的过长是指用户界面没有响应,还是在用户界面中看到图像之前过长?另外,为了了解为什么加载图像需要很长时间,您应该提供加载图像的代码。@fmt.Println.MKO在UI中看到图像之前,加载图像的时间太长了。您的代码是如何加载图像的,以及它是否会发生在所有图像上?也许你的图像很大?我正在使用库
nostra13/Android通用图像加载程序
加载图像。因此,
ImageLoader…loadImageSync
正在加载位图。我的图像是用三星galaxy S3拍摄的普通图像,请看下面的文档:,我假设您不使用缓存,而是将整个图像加载到gridview中,而加载一个小版本(缩放)版本。它也存储在文件缓存中
ImageLoader.getInstance().displayImage("file://" + image.cardPath, imgQueue);

**Bitmap bitmap = ImageLoader.getInstance().loadImageSync("file://" + image.cardPath, Utility.displayImageOptions);**

wrongImageSign.setVisibility(imageRatioIsBad(bitmap) ? View.VISIBLE : View.INVISIBLE);