2011-11-22 76 views
0

我做了我的布局基于模拟器,但只是在实际设备上运行我的应用程序,所有的布局搞砸了。我不知道如何解决它。这里是我的XML文件中的代码,Android布局搞砸了电话

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:background="@drawable/mainback" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="23dip" 
    android:layout_marginRight="15dip" 
    android:layout_marginTop="255dip" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="276dp" 
     android:layout_height="132dp" 
     android:textSize="15dp" 
     android:gravity="center_vertical" 
     android:text="some text" 
     android:textColor="#4C2016"/> 

    <Button 
     android:id="@+id/special" 
     android:layout_width="131dp" 
     android:layout_height="40dp" 
     android:background="@drawable/cc" 
     android:layout_marginTop="20dip" 
     android:layout_marginLeft="75dip" 
     android:textSize="17dp" 
     android:textStyle="bold" 
     android:text="Specials" 
     android:textColor="#F6E6C6" /> 
</LinearLayout> 

`

这将是真棒一些人能告诉我如何解决此问题的代码

这里是什么样子的快照xml文件

enter image description here

这是怎么看起来像在手机上,

enter image description here

图像和橙色文本是背景图像的一部分,并且textview和按钮被添加到视图中。

+7

下你有没有在手机上的穷人布局的屏幕截图替换“match_parent”与“FILL_PARENT”?你能告诉我们与模拟器相比布局究竟有什么问题吗? –

+1

你必须定义“搞砸”,否则......我们不知道“搞砸”是什么意思。 – Jack

+0

你可以发布到底是什么东西,它看起来有多必要? –

回答

0

您正在使用哪个API级别? 因为我看到你在同一个文件中使用“fill_parent”和“match_parent”。从API级别8开始,fill_parent被替换为math_parent。 我还与与API级别低于8项目使用match_parent(这是不承认“),反之亦然FILL_PARENT给我布局的问题在一个项目中使用API​​ 8或更高的问题。

但更好的帮助你,请把你的运行APP的一些截图。因此,我们可以更清楚地看到什么是你的布局问题。

有很好的发展!

0

的硬编码值使得根据设备屏幕大小和分辨率的布局看起来不同。

而不是依靠边缘哈哈ve下面的文字('android:layout_marginTop =“255dip”)你可以把图像放在ImageView中。您的TextView将被定位在图像下方。使用imageview上的底部边距或文本视图上的顶部边距微调距离。

将'wrap_content'用于TextView的* layout_height *,将'fill_parent'用于* layout_width *而不是固定值。

而且 - 如果你的应用是针对API比8

<LinearLayout> 
    <ImageView/> 
    <TextView/> 
    <Button/> 
</LinearLayout>