我想在屏幕的橫向模式中將劃分的屏幕設計爲兩個不相等的部分。所以,我認爲自動使用片段。但是我遇到的問題是每個片段都與屏幕的一半相匹配。這不是我想要的。我想要的是兩部分寬度不相等的屏幕。我想是這樣的:如何設置每個片段的屏幕百分比
1
A
回答
2
你可以利用重量參數。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3" />
</LinearLayout>
請注意用於兩個LinearLayout的權重。第一個權重爲1(可以佔用屏幕的1/4),第二個權重爲3(可以佔用屏幕的3/4)。
只要使用這個完全相同的概念爲您的片段,並保持不變的比例,如你所願。
希望我能說清楚。
+0
謝謝Aritra – HiddenDroid
0
使用重量參數
<LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent">
<LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent"/>
<LinearLayout android:layout_weight="3" android:layout_height="fill_parent" android:layout_width="fill_parent"/>
</LinearLayout>
+0
fill_parent已被棄用,因爲sdk 8.請使用match_parent – Eenvincible
0
組線性佈局重量實現這個...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
相關問題
- 1. DIV高度設置爲屏幕百分比?
- 2. FrameLayout和屏幕的百分比
- 3. 屏幕座標到百分比轉換
- 4. 帶位置的屏幕的CSS百分比:絕對
- 5. 如何設置fillRect百分比
- 6. 如何在不同的屏幕尺寸用百分比字體
- 7. 如何設置一個臨時片段到我的「主屏幕」Android工作室
- 8. 文本框的CSS fontSize的設置,以百分比不全屏
- 9. 在ViewPager的每個屏幕中使用多個片段
- 10. 如何在UIsegment控件中爲每個片段設置圖片
- 11. 高度百分比變成圖片的高度而不是屏幕
- 12. 如何設置Appium在每個動作上拍屏幕
- 13. 獲取每個級別的百分比
- 14. jquery - 計算每個值的百分比
- 15. 如何將整個屏幕的片段最小化到我的屏幕底部
- 16. Fabric js如何設置百分比對象的位置
- 17. 在jQuery中,如何以百分比設置元素的位置?
- 18. 的Javascript變量 - 設置爲百分比
- 19. 檢測屏幕上的一個片段
- 20. Google Charts:如何獲取餅圖中每個切片的百分比值?
- 21. 每個ID的字段出現百分比
- 22. 允許佈局佔據屏幕空間的百分比?
- 23. 每月百分比計算
- 24. dplyr每組百分比
- 25. php mysql計算每個百分比
- 26. 如何在html頁面中設置svg高度(以屏幕百分比爲單位)
- 27. 屏幕方向和片段
- 28. KineticJS:設置寬度基於百分比
- 29. 使用jQuery設置寬度百分比
- 30. 使用百分比來計算出基於屏幕resoultion的位置在c#
發佈你試過的東西,直到 – koutuk
權重被引入您的需要 – Eenvincible