为什么我的形象在横向模式下消失? [英] Why is my image disappearing in landscape mode?

查看:135
本文介绍了为什么我的形象在横向模式下消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在纵向模式下,这是正确显示图像。当我更改配置为横向,不显示图像。

I have an image in portrait mode, which is displayed correctly. When I change the configuration to landscape, the image is not displayed.

请注意,的LinearLayout ,内附的ImageView 是正确的显示出来(我检查通过更改背景)。但是,当我改变了的ImageView 后台,后台也没有显示。

Note that the LinearLayout, enclosing the ImageView is displayed right(I checked it by changing the background). But when I changed the background for the ImageView, the background was also not shown.

   <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:layout_weight="3">
           <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:minHeight="48dp" android:minWidth="48dp" android:src="@drawable/xyz" android:id="@+id/img"/>

推荐答案

OK,您的布局文件是不必要的大和复杂的。所以让我们尝试一些东西 -

OK, your layout file is unnecessarily large and complex. So let's try a couple of things-

首先,尝试创建XML文件的简单版本,包含了准系统显示图像。如果在纵向和横向的作品,你知道,这个问题是不是你的活动或你的形象。

First, try creating a simple version of your XML file that contains the barebones for displaying the image. If that works in both portrait and landscape, you know that the problem is not your activity or your image.

如果第一步工作,下一步将是在简化您的布局文件时,有可能被剪掉了不少。它深藏在分七层,应该几乎从不发生的。 这里是一个很好的博客文章由上更好的布局设计的Andr​​oid工程师。你可以在别的地方找到类似的资源。

If the first step works, the next step would be to work on simplifying your layout file, there is a lot that could be pruned. It goes seven layers deep at points, that should almost never happen. Here is a good blog post by an Android engineer on better layout design. You can find similar resources elsewhere.

这篇关于为什么我的形象在横向模式下消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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