I have linear layout with viewpager on top and another vew (button in this example) bottom. Views in the pager have different heights. I would like the pager to have wrap_content
height on all pages and button view to fill the rest of the screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="New Button"
android:id="@+id/button3"
android:layout_weight="1"/>
</LinearLayout>
This doesn't work. If I give layout_weight=1
to both pager and button, they share screen 50:50 no matter of content height. I tried to call requestLayout()
in ViewPager.OnPageChangeListener.onPageSelected()
but it doesn't help. Also tried this