I am trying to use match_parent height for my ViewPager to replace the fragment. But either layout_height="match_parent" or "wrap_content" not working. If i use them then my views become invisible.
Why does it only works when i do specify in dp? How do i make it to match_parent.
My XML Layout code: This is Fragment Layout replaced with FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Fragments.Frag.MyFragment">
<com.google.android.material.tabs.TabLayout
android:background="@drawable/toolbar"
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.viewpager.widget.ViewPager
android:background="#f1f1f1"
android:id="@+id/Viewpager"
android:layout_width="match_parent"
android:layout_height="600dp"/>
</LinearLayout>
My MainActivity which replaces above XML into FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white_light2"
android:fitsSystemWindows="true">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
app:layout_scrollFlags="scroll|enterAlways"
style="@style/customToolBar"
android:id="@+id/toolbar1"
app:title="Home">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_marginBottom="?attr/actionBarSize"
android:id="@+id/FragmentHolder"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</androidx.core.widget.NestedScrollView>
</androidx.drawerlayout.widget.DrawerLayout>
Output i am getting as
How can i avoid specifying ViewPager height in dp to take the entire screen space (match_parent)
