2012-04-01 30 views
0

我正在开发一个针对android的应用程序。我的主布局是一个RelativeLayout。安卓版面在一个小设备上被拉伸了

当我在大屏幕模拟器中打开应用程序进行调试时,一切正常。 但是当我在QVGA设备上打开它时,我发现布局失真。

我是否真的需要为每个屏幕尺寸制作新的布局?我已经看到在一些地方是机器人可以自动伸展一切以适应布局...

Developer.android.com说:

默认情况下,Android的重新调整你的应用程序布局,以适应当前设备屏幕。

http://developer.android.com/guide/practices/screens_support.html

能否请你帮我弄清楚为什么布局看起来扭曲离子的小型设备? 正如您所看到的那样,图像确实会拉伸,但布局显示效果不佳。

在此先感谢!

Big Screen Image http://www.interload.co.il/upload/6549026.png Small Screen Image http://www.interload.co.il/upload/9617759.png

编辑:存在问题的网页 XML代码。 所有图形都在“drawable-hdpi”文件夹中,但问题不在于图像本身,而在于布局。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/background" xmlns:android1="http://schemas.android.com/apk/res/android"> 
<ImageView 
    android:id="@+id/selectionHead" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:src="@drawable/header" /> 


<ImageView 
    android:id="@+id/chooseFormatTxt" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/selectionHead" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="20dp" 
    android:src="@drawable/step1_choose_format" /> 

<ImageView 
    android:id="@+id/videoBtn" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="42dp" 
    android:onClick="VideoClick" 
    android:src="@drawable/step1_video" /> 


<ImageView 
    android:id="@+id/orTxt" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/videoBtn" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="19dp" 
    android:src="@drawable/step1_or" /> 

<ImageView 
    android:id="@+id/audioBtn" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/orTxt" 
    android:layout_alignLeft="@+id/videoBtn" 
    android:layout_marginBottom="22dp" 
    android:layout_centerHorizontal="true" 
    android:onClick="AudioClick" 
    android:src="@drawable/step1_audio" /> 

<ImageView 
    android1:id="@+id/step1Share" 
    android1:layout_width="wrap_content" 
    android1:layout_height="wrap_content" 
    android1:layout_alignBottom="@+id/selectionHead" 
    android1:layout_alignParentRight="true" 
    android:layout_marginBottom="10dp" 
    android:layout_marginRight="5dp" 
    android1:src="@drawable/share" /> 

</RelativeLayout> 
+0

你有硬编码的图像位置的布局,多数民众赞成Ÿ它的外观不同的行为。 – 2012-04-01 12:46:58

+0

没有足够的信息在这里给出 - 发表您的布局XML,让我们知道什么文件夹(或多个)您可绘制在 – areyling 2012-04-01 13:39:16

+0

尝试更加具体,当你永远有任何查询,并尽量提供您的问题 – Ishu 2012-04-01 13:58:54

回答

2

我是不是真的需要为每一个屏幕尺寸的新布局?

当您现有的布局不起作用并且您选择制作新布局而不是以其他方式解决问题时,您需要进行新布局。

请你帮我弄清楚为什么布局会扭曲离子小设备?

您的布局是完全正常的,因为它是做正是你告诉它做的事:

  • 视频按钮布局
  • 的“或”线的底部上方42dp在视频按钮上方19dp
  • 音频按钮22dp上面的“或”线路

即83dp加的各种图像的尺寸,whic h显然使它太高。

如果不是你想让它在小屏幕上做什么,或者:

  • 拿出一个不同的布局-small设备,或
  • 使用方面的资源,而不是硬编码值,并使用不同的值,这些维度-small设备,或
  • ...
+0

感谢-很多。你解决了我的问题。 – 2012-04-01 14:16:07