Nexus 5(Android 6.0)中未显示imageView [英] imageView is not shown in Nexus 5 (Android 6.0)

查看:162
本文介绍了Nexus 5(Android 6.0)中未显示imageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在RelativeLayout中有一个ImageView:

I have an ImageView in a RelativeLayout:

    <ImageView
        android:id="@+id/image"
        android:src="@drawable/image1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

它可以在许多设备(手机和平板电脑)和仿真器上运行,但不能在具有Android 6的Google Nexus 5上运行.该应用程序可以正常运行,但不会显示ImageView背景.

It works on many devices (phones and tablets) and emulators, but does not work on Google Nexus 5 with Android 6. The application works perfectly but the ImageView background is not displayed.

(图像位于可绘制文件夹中,我使用setImageResource更改了图像)

(Image is in drawable folder and I change the image with setImageResource)

推荐答案

我也遇到了同样的问题,即我的图像显示在所有其他Android版本的Android 6.0中. 我正在android 5.0和android 6.0中测试我的应用程序,该时间图像在android 5.0中正确显示,但在android 6.0中图像未加载到Imageview中.

I also got the same problem, in which my image show in all android version rest of Android 6.0. I was testing my application in android 5.0 and android 6.0, that time image shown properly in android 5.0 but in android 6.0 image does not load in Imageview.

我已经使用src和background两个属性,但是没有在android 6.0的Imageview中获得图像.

I have used src and background both property but did not get the image in Imageview in android 6.0.

然后,要解决此问题,我检查了logcat,并在logcat中找到了下面的字符串.

Then, To solve this problem I checked my logcat and I got below string in logcat.

W/OpenGLRenderer:位图太大,无法上传到纹理中(3240x5760,max = 4096x4096)

W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3240x5760, max=4096x4096)

我搜索了与此字符串相关的内容并获得了解决方案,这是Android 6.0不允许在UI Thread中执行繁重的过程.如果图像的尺寸和分辨率较小,则可以使用src或background进行加载.但是您的图片太重,则Android 6.0会在UI线程中跳过此过程.

I searched related this string and got the solution for this, it is Android 6.0 does not give permission to do the heavy process in UI Thread. If your image is small in size and resolution, then you can use src or background for the load it. but your image is too heavy then Android 6.0 skip this process in UI Thread.

但是,您可以使用以下解决方案来解决此问题.

But, You can solve this by use of below solutions.

解决方案1 ​​:

通过使用第三方库(如 Glide )来解决此问题,以加载大量图像. 我已经用它解决了.

Resolve it by use of third party library like Glide for load heavy images. I have solved it with the use of this.

解决方案2 :

res中添加一个drawable-nodpi文件夹,将图像放入其中,然后将其与Imageview标记中的src一起使用.

Add a drawable-nodpi folder in res, put the image in it and simply use it with src in Imageview tag.

这篇关于Nexus 5(Android 6.0)中未显示imageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆