2011-11-22 74 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>