1
所以我想在屏幕上有三個部分。頂級的「工具欄」 - 大概佔用了屏幕10%的東西。我將稍後填寫的數據佔用了屏幕的70%,最後是底部搜索欄的20%的屏幕。Layout_Weight給予意想不到的結果
我認爲這將是一件簡單的事情:3個線性佈局子項的線性佈局,其權重分別爲0.1,0.7和0.2。但是,這不起作用。當我更改某些視圖的layout_weight時,它會更改其他視圖佔用的屏幕數量。下面的代碼我在此刻:
<?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:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.95"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@android:color/transparent"
>
</LinearLayout>
</LinearLayout>
這給了我第一個空的佈局,佔據了20%的屏幕(是的,有0.95的重量),第二個空的佈局佔用的80%屏幕和最終的佈局是空的。當我給最終版面設計一個0.1的權重時,它會給第一個版面留出更多的空間。我認爲我有一些流氓格式。
我需要學習閱讀 –