ImageView 显示在布局中但不在实际设备上

ImageView displaying in layout but not on actual device(ImageView 显示在布局中但不在实际设备上)

本文介绍了ImageView 显示在布局中但不在实际设备上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想要显示的与设备的全宽匹配的 ImageView,我意识到是这样的:

I have an ImageView that I want to display matching the full width of the device, I realized that like this:

<ImageView
    android:id="@+id/home_bar_newvault"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:scaleType="centerCrop"
    android:layout_alignParentBottom="true"
    android:src="@drawable/home_bar" />

home_bar 是一个 PNG 图像文件,尺寸如下:2399x254.当我选择查看 UI 的图形布局时,它会在活动底部正确显示图像视图.但是,当我在设备上启动应用程序时,它根本不会显示 Imageview.

The home_bar is a PNG image file with the following dimensions: 2399x254. When I choose to view the Graphical Layout of the UI it displays the imageview correctly at the bottom of the activity. However, when I start the application on my device it won't display the Imageview at all.

推荐答案

好吧,我已经尝试更改图像的分辨率(将其切成两半,使其成为 1000x130),并以某种方式解决了问题.我认为Android不能直接渲染这样的大图像?我不知道,如果您对主题有更多了解,请不要犹豫回复!无论如何,缩小图像是可行的.

Alright I've tried changing the resolution of the image (cutting it in half making it 1000x130), and somehow that fixed the problem. I think Android can't render large images like that directly? I don't know, if you know more about the subject please don't hesitate to reply! Anyway, scaling down the image worked.

这篇关于ImageView 显示在布局中但不在实际设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:ImageView 显示在布局中但不在实际设备上

基础教程推荐