任何人都可以告訴我如何創建這樣的佈局嗎?我有中間元素的問題。 製作android佈局,寬度不對
0
A
回答
1
您是否需要中間視圖或其中三個?
對於前者,只需在左側和右側創建一個60dp填充的視圖。
對於後者,創建60dp寬度的固定邊緣視圖,對於中間的視圖,設置以下屬性:layout_width的0dp和layout_weight的1。
將所有這些視圖放入LinearLayout中。
1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="60dp"
android:layout_height="fill_parent"
android:background="#333333"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#FF3333"
/>
<FrameLayout
android:layout_width="60dp"
android:layout_height="fill_parent"
android:background="#333333"
/>
</LinearLayout>
0
的線性佈局與3個元素內:
左右elemend會有機器人:layout_width = 「60dp」,而中央的一個將具有:
android:layout_width="0dp"
android:layout_weight="1"
在
這樣它就會適應設備屏幕寬度
0
只需在任何元素中使用layout_margin
屬性,例如TextVi ew:
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:background="#ff0000" />
相關問題
- 1. Boostrap.css製作佈局100%寬度/高度
- 2. Android最小寬度佈局
- 3. Android,佈局屏幕寬度
- 4. Android佈局邊距製作寬度爲0
- 5. 在Android佈局XML中使用可繪製寬度作爲值
- 6. Android佈局高度和寬度
- 7. 佈局寬度css
- 8. JTable寬度佈局
- 9. Android的佈局控制表高度和寬度包含
- 10. 設置android的相對佈局的高度和寬度
- 11. 的Android get和set佈局寬度
- 12. Android桌面佈局寬度概率
- 13. Android的佈局圖像填充寬度
- 14. Android的佈局 - 按鈕寬度
- 15. Android EditText佈局寬度全尺寸
- 16. Android圖像寬度填充佈局
- 17. Android片段佈局的寬度錯誤
- 18. Android佈局等寬和高度
- 19. 的Android百分比寬度佈局
- 20. Android:在佈局中獲取寬度
- 21. Android動態設置textview佈局寬度
- 22. Android的重量和佈局寬度
- 23. Android相對佈局高度
- 24. Android佈局 - 製作可滾動佈局
- 25. 機器人:相對佈局寬度WRAP_CONTENT
- 26. 動畫相對佈局寬度變化
- 27. Android佈局最大寬度或屏幕寬度?
- 28. Android按鈕寬度的一半可用寬度 - 佈局
- 29. android佈局最小寬度(sw800dp)和不同密度
- 30. Android佈局:即使寬度/高度爲0,重量也不起作用
非常感謝,左側和右側的填充解決了我的問題:)我可以使用layout_weight =「1」或layout_width =「fill_parent」,兩者都可以正常工作 – krinn 2012-07-12 20:49:03