重疊視我有以下佈局結構:如何避免RelativeLayout的
<RelativeLayout>
<ScrollView>
<LinearLayout>
<RelativeLayout>
<LinearLayout android:id="@+id/ContentNo1"> <-- Align top
</LinearLayout>
<LinearLayout android:id="@+id/ContentNo2"> <-- Align bottom
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<Button/> <-- Always bottom of the page
</RelativeLayout>
我的按鈕是底端對齊在第一RelativeLayout的,和我的滾動型頂端對齊在它...
我想在第二個RelativeLayout中將ContentNo1頂部對齊,並在底部對齊ContentNo2 ...
我已經這樣做了,但是當ContentNo1變得太大,它與ContentNo2重疊時,我希望它只是推送ContentNo2下...如何做到這一點?
我已經試過(如在某些話題在這裏詳細介紹),使用layout_below/layout_above,但是當我使用它時,ContentNo2的下對齊被解僱......
- 編輯 -
由於瓦斯問,這裏是一些圖片:(我不能發佈超過2個鏈接,然後我做了這個網頁來解釋它)
http://www.mydonorlife.hol.es/relativeissue/
- EDIT 2 - 解決方案 -
這個工作對我說:我已經刪除了第二RelativeLayout的,並設置一些看法如下>>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- CONTENT NO 1 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="30dp">
</LinearLayout>
<!-- /CONTENT NO 1 -->
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="0dp">
<!-- CONTENT NO 2 -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:gravity="bottom"
android:layout_height="match_parent"
android:layout_weight="0">
</LinearLayout>
<!-- /CONTENT NO 2 -->
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:layout_alignParentBottom="true"/>
</RelativeLayout>
希望它的一些體重/身高的技巧幫助別人後...
您可以使用匹配父外的LinearLayout,使其全屏幕,然後用layout_below/layout_above。然後底部對齊不會消失。因爲使用layout_below/layout_above可以確保兩個相對佈局之間沒有重疊。 –
這外的LinearLayout已經設置與match_parent高度和底部對齊不斷消失,當我使用layout_below /上述 –
下對齊消失意味着內容2是無法適應屏幕的休息嗎?你能分享一張照片嗎?一張圖片可能會更好地描述這個問題! –