我是新的Android平臺。我試圖製作一個視圖,將屏幕分爲三部分。第一部分應該是200dip高,第三部分應該是50高,中間部分應該留在中間的剩餘部分。有什麼辦法可以實現它嗎?我嘗試了一些方法,但是它不起作用或應用程序崩潰。 感謝您的幫助 Patrik動態視圖高
Q
動態視圖高
1
A
回答
1
當然。使用一個看起來像這樣的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">
<!-- Defining the top view -->
<View android:layout_alignParentTop="true"
android:layout_height="200dip"
android:layout_width="fill_parent"
android:id="@+id/top_view"
android:background="#FFFF00"/>
<!-- Defining the bottom view -->
<View android:layout_alignParentBottom="true"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:id="@+id/bottom_view"
android:background="#00FFFF"/>
<!-- Defining the view in between those views -->
<View android:layout_above="@id/bottom_view"
android:layout_below="@id/top_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF0000"/>
</RelativeLayout>
在代碼中爲您提供了註釋。
0
我通常通過設置固定視圖爲特定值(例如android:layout_height="200dp"
)layout_height /寬度,並用爲android:layout_height="wrap_content"
動態查看設置android:layout_weight="1"
實現這一點。在這種情況下,LinearLayout應該被用作包含ViewGroup。
相關問題
- 1. NSLayoutConstraint - 超級視圖的動態高度
- 2. 動態聲明視圖高度
- 3. UITableViewCell中動態高度的子視圖
- 4. 列表視圖動態項目高度
- 5. UITableViewCell高度動態子視圖swift
- 6. 動態addSeries高圖
- 7. 基於父寬度的動態視頻視圖高度
- 8. 動態表格視圖+滾動視圖
- 9. 將動態高度UITableView添加到滾動視圖中?
- 10. 使用自動佈局的動態高度的網格視圖
- 11. 在Swift中使用動態高度滾動視圖
- 12. 高級移動視圖
- 13. grails動態視圖
- 14. Android圖形,動態視圖
- 15. 如何使用動態高度在子視圖下方定位子視圖?
- 16. iReport - 動態圖像或圖像高度
- 17. 高圖柱形圖動態更新ajax
- 18. knockoutJS動態圖表與高圖表
- 19. 如何根據多個視圖配置動態UITableViewCell的高度
- 20. 動態更改包含集合視圖的單元格高度
- 21. 如何將動態高度設置爲列表視圖
- 22. iOS動態桌面視圖沒有UILabels的單元格高度
- 23. 子視圖裏面的UIScrollview高度變化動態
- 24. 如何在動態添加視圖後獲取StackLayout的高度?
- 25. iOS8 - 具有動態高度的鍵盤輸入附件視圖
- 26. 用動態高度固定視圖底部
- 27. 使用Core Text動態更改視圖高度
- 28. 獲取UITabelViewCell中的視圖高度動態變化
- 29. 目標c - 動態調整視圖高度
- 30. Android文本視圖高度變化動態
我喜歡這個建議甚至比我的更好。 +1 – Ralkie 2010-10-27 09:44:01