我试图将 View 分页器放在表行中,并将 View 分页器的布局高度设置为父级。结果是 View 寻呼机根本没有高度。我必须在dp中设置布局高度,以便 View 寻呼机可以具有高度。但是我在 View 分页器中进行的充气是动态的,因此无法在xml中设置高度。滚动 View 已经填满了屏幕,但是viewpager根本没有任何高度。有什么办法可以解决这个问题? (有问题的 View 分页器是具有id pager_problem的 View 分页器)
编辑 :
好的,现在,在更改它之后,viewpager存在,但仅与屏幕一样大,如果 fragment 内容很长,我想使viewpager内的内容可滚动(所有布局均可滚动,不仅是view pager中的 fragment )
<?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>
最佳答案
您需要将android:fillViewport="true"
设置为scrollview
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
关于android - 在scrollview中匹配viewpager的父项不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25969031/