2011-05-14 61 views
0

有沒有辦法在屏幕上將較低內容與較低內容分開?所以不管上面的區域是什麼,下面的區域都在屏幕的底部。我試過重力=底部和類似的東西。我試過在頂部和底部之間插入某種佈局,希望它能保持擴展(從而將兩者分開)。謝謝你盡你所能的幫助。動態擴大空白空間?

回答

2

答:RelativeLayout的

例子:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TextView 
     android:text="TOP" 
     android:layout_alignParentTop="true" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
    </TextView> 
    <TextView 
     android:text="BOTTOM" 
     android:layout_alignParentBottom="true" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
    </TextView> 
</RelativeLayout> 
+0

那偉大工程,我睜開眼睛:)。它在縱向上做了訣竅,但是在橫向上,底部對齊的東西與頂部的東西重疊。有沒有辦法在活動的onCreate中改變這種情況,以便如果它的風景是假的,如果肖像是真的?感謝您的幫助 – Metallicraft 2011-05-15 00:07:43

+0

嘗試使用其他屬性,如android:layout_below及以上。如果您分別進行了縱向和橫向佈局,最好的做法是。 – pawelzieba 2011-05-15 00:11:24