Reputation: 145
I am trying to make a two pane layout for my app, and i'm trying to use layout_weight
but its not working correctly. It looks like it's reversed so that the view with more weight is smaller but when I checked it didn't even do that. Here is my 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>
Upvotes: 0
Views: 972
Reputation: 16651
I don't know the exact reason why this happens, but if you change the layout_width
of the root element to match_parent
it will work correctly.
Upvotes: 1
Reputation: 25761
The outer LinearLayout
has width wrap_content
, change it to match_parent
Upvotes: 2