0

I set ViewPager's height wrap_content but it doesn't work. I tried answers in other similar questions but they didn't solve my problem. my activity_main code is this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#C49A1544"
    tools:context=".MainActivity">

    <include layout="@layout/toolbar"
        android:id="@+id/main_toolbar"/>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/viewpager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/standard_margin_x2"
        android:layout_below="@id/main_toolbar"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true" />

</RelativeLayout>

and I have 3 fragment layouts. really sorry for my low English, I am a beginner in Android app development please help me.

1 Answers1

0

I found a solution myself. If we use UltraViewPager library instead of the default, the problem will be solved, but this library has bugs. Anyway, thank you for trying to help me with your comments.