佈局高度0dp我要實現以下目標:的Android使用兩個孩子和家長
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.42">
<ListView
android:id="@+id/ist"
android:layout_width="match_parent"
android:layout_height="0dp" <!-- GETTING ERROR : Suspicious size: this will make the view invisible, probably intended for layout_width -->
android:layout_weight="1"
android:background="@color/Bkgd"
android:transcriptMode="alwaysScroll"
android:stackFromBottom="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@android:color/white" >
<Button android:id="@+id/Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/input_btn"
android:background="@android:color/white" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.58"
android:background="@color/colorPrimary" >
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:columnWidth="30dp"
android:numColumns="auto_fit"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
我已經標註在上面的代碼中的Android Studio顯示佈局錯誤。
使用上述佈局,我得到輸出:
我應當怎樣更改有佈局像第一張圖片?
只是讓ListView的高度WRAP_CONTENT(因爲現在0 DP無所謂),並從ListView和linearlayoutholder刪除佈局權重,並刪除方向(不需要)從相對佈局 – user5155835
然後我就標誌着你的答案 – user5155835