Parent match for viewpager inside scrollview not working

I am trying to put a view pager inside a table row, and I set the height of the pager view layout to match the parent. the result is that the presentation pager has no height at all. I have to set the layout height in dp so that the view pager can have a height. But what I am inflating inside the view pager is dynamic, so I cannot set the height inside xml. Scrollview already fills the screen, but the viewpager has no height at all. Is there any way around this? (viewing a pager that has a problem is one that has id pager_problem)

EDIT:

okay, now, after I changed it, the viewpager exists, but only the size of the screen, I want to make the content inside the scroll viewpager if the content of the fragment is long (all layouts scroll, not just the fragment in the view pager)

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.emilsjolander.components.StickyScrollViewItems.StickyScrollView
        android:layout_width="match_parent"
        android:fillViewport="true"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="wrap_content">
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <TableRow>
                    <android.support.v4.view.ViewPager
                        android:id="@+id/pager_image"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="100dp" />
                </TableRow>
                <TableRow android:tag="sticky">
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="50dp"
                        android:id="@+id/tab"
                        android:tag="sticky"
                        android:layout_below="@id/pager_image"
                        android:orientation="horizontal">

                        <LinearLayout
                            android:id="@+id/frame_general_tab"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:textSize="15dp"
                                android:text="GENERAL"/>
                        </LinearLayout>
                        <LinearLayout
                            android:id="@+id/frame_detail_tab"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:background="@color/gray_F2">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:textSize="15dp"
                                android:text="DETAIL"/>
                        </LinearLayout>

                        <LinearLayout
                            android:id="@+id/frame_foto_tab"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:background="@color/gray_F2">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:textSize="15dp"
                                android:text="FOTO"/>
                        </LinearLayout>
                    </LinearLayout>
                </TableRow>
                <TableRow>
                    <!--<LinearLayout android:id="@+id/page_container"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:orientation="vertical"
                        android:layout_marginBottom="70dp"
                        android:layout_height="match_parent">
                    </LinearLayout>-->
                    <android.support.v4.view.ViewPager
                        android:id="@+id/pager"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_marginBottom="70dp"
                        android:layout_height="match_parent"/>

                </TableRow>
            </TableLayout>


        </LinearLayout>
    </com.emilsjolander.components.StickyScrollViewItems.StickyScrollView>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="wrap_content">

        <GridLayout
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"
            android:columnCount="2"
            android:background="@color/gray_F2"
            android:rowCount="3"
            android:orientation="vertical"

            android:layout_height="70dp">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="20dp"
                android:textSize="15dp"
                android:layout_gravity="right"
                android:textColor="@color/gray_72"
                android:text="Harga mulai"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:textSize="20dp"
                android:layout_gravity="right"
                android:text="Rp 10.560.000"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="20dp"
                android:textSize="15dp"
                android:layout_gravity="right"
                android:textColor="@color/gray_72"
                android:text="per kamar per malam"/>

            <Button android:layout_width="150dp"
                android:layout_marginLeft="20dp"
                android:layout_height="match_parent"
                android:layout_rowSpan="3"
                android:background="@color/traveloka_button_orange"
                android:textColor="@color/white"
                android:layout_margin="10dp"
                android:text="LIHAT KAMAR"/>

        </GridLayout>
    </RelativeLayout>
</RelativeLayout>
+5
source share
1 answer

You need to set android:fillViewport="true"to scroll view

android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
+14
source

All Articles