ImageView我无法显示图像
我创建了非常简单的android应用程序,它显示图像。 代码:ImageView我无法显示图像
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/textView1"
android:scaleType="matrix"
android:src="@drawable/img_big_size"
/>
</RelativeLayout>
此外我有两个相同的图片,第一img_big_size.jpg(尺寸468 KB)和第二img_small_size.jpg(尺寸192 KB)。 第一个图像具有更高的分辨率,因此需要比第二个图像更多的内存。 当我尝试显示第二个图像(img_small_size.jpg)应用程序工作正常,并显示图像。 但是,当我尝试显示拳头图像(img_small_size.jpg)应用程序不显示图像只显示黑屏。为什么我的应用程序无法显示第一个图像如何显示第一个图像?
我想显示第一张图片,因为当我首先放大图片时,图片比第二张图片更清晰。 。
你的大图像尺寸是扪:1571x2166
OpenGLRenderer硬件加速不能处理位图比为2048x2048大。您可以尝试通过在AndroidManifest.xml文件中的内定义android:hardwareAccelerated =“false”来禁用硬件加速。
<application
android:hardwareAccelerated="false"
android:largeHeap="true" >
或为了获得最佳性能,您可以在显示图像之前调整图像大小。 保留大堆会显着降低您的应用性能。
如果我设置了android:hardwareAccelerated =“false”,会导致任何不好的后果吗? – 2014-09-24 19:29:41
阅读http://developer.android.com/guide/topics/graphics/hardware-accel.html – 2014-09-24 19:46:19
是的,如果你禁用该功能,它会增加你的应用程序RAM的使用量,并使你的应用程序资源消耗的应用程序!这不好。使用GPU渲染图像的性能也会好得多。 – 2014-09-24 19:47:34
其中textView1在你的XML? – yrazlik 2014-09-24 19:29:47