我正在尝试为我的应用程序制作两个窗格布局,并且我正在尝试使用layout_weight
但它无法正常工作。看起来它被颠倒了,因此重量更大的视图更小,但是当我检查时它甚至没有这样做。这是我的xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<EditText
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search" >
<requestFocus />
</EditText>
<ListView
android:id="@+id/bookList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<fragment
android:id="@+id/fmtEditBook"
android:layout_weight="2"
android:layout_height="match_parent"
android:layout_width="0dp"
android:name="com.perlib.wmbg.fragments.EditBookFragment"
tools:layout="@layout/fragment_edit_book" />
</LinearLayout>