1
Q
幫助佈局類型
A
回答
1
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:background="#ff00" android:id="@+id/relativeLayout1"
android:layout_height="100dp" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"></RelativeLayout>
<RelativeLayout android:layout_width="match_parent"
android:background="#f0f0" android:id="@+id/relativeLayout2"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_above="@+id/relativeLayout1"
android:layout_centerHorizontal="true"></RelativeLayout>
</RelativeLayout>
1
如果您的佈局很簡單,只要在上面顯示,我會使用的LinearLayout - 主要是因爲我覺得相對佈局有點惱人,更難找到的bug工作
的樣本會。是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/linearLayout1"
android:orientation="vertical" android:layout_weight="1"
android:background="@android:color/darker_gray">
<!-- Put widgets here -->
</LinearLayout>
<LinearLayout android:layout_height="100dp"
android:layout_width="fill_parent" android:id="@+id/linearLayout2"
android:orientation="vertical" android:background="@android:color/background_light">
<!-- Put widgets here -->
</LinearLayout>
</LinearLayout>
相關問題
- 1. 幫助佈局
- 2. WPF佈局幫助
- 3. Android佈局幫助
- 4. 幫助CSS佈局
- 5. Android佈局幫助
- 6. Android佈局幫助(類似於靜態)
- 7. 圖標佈局幫助
- 8. 佈局設計幫助Android
- 9. 幫助使用CSS佈局
- 10. Android的佈局幫助
- 11. 數據庫佈局幫助
- 12. 動態CSS佈局幫助
- 13. Android應用佈局幫助
- 14. 幫助我的WPF佈局
- 15. Android片段佈局幫助
- 16. 佈局需要幫助
- 17. 代碼佈局幫助
- 18. 佈局幫助,消失LinearLayouts
- 19. Android佈局設計幫助!
- 20. jQuery的幫助,佈局
- 21. 幫助與CSS佈局
- 22. CSS/HTML佈局幫助
- 23. 有關android佈局的幫助?
- 24. 黑莓幫助對齊此佈局
- 25. Android應用程序佈局幫助
- 26. 需要幫助創建佈局
- 27. 需要幫助瞭解自動佈局
- 28. Android的佈局設計幫助
- 29. Magento - 幫助指定頁面佈局
- 30. 在android中的佈局幫助
夫婦的筆記,第一線性說,高度WRAP_CONTENT,並不意味着它會擴大,因爲內容被添加?第二條線是否位於屏幕的底部?它看起來就像坐在最下面的那個下面。 – dotty
這裏的訣竅是第一個LinearLayout的layout_weight =「1」。這有助於告訴佈局佔用所有可用空間 - 無論其內容或自己的layout_height值如何。這也將第二個佈局定位在屏幕的底部,因爲它只佔用100dp的高度,剩下的部分用於第一個佈局。 – kaspermoerch