In my android application, I want to implement PagerSlidingTab and ViewPager
inside ScrollView
. The layout file is shown below. I am facing a weird problem in that. It shows only tab strip on top and no content is displayed for ViewPager
Fragment content on screen. I don't know what is the problem with that. If I remove ScreollView from layout then it works perfectly but I want everything inside ScrollView
. Please help me to solve this issue.
Layout :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.danzim.diamond.classes.KenBurnsView
android:id="@+id/newsHeaderKenburn"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentTop="true"
android:background="@color/black" />
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/newsTabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@+id/newsHeaderKenburn"
android:background="@drawable/background_news_tab"
app:pstsDividerColor="@color/transparent"
app:pstsIndicatorColor="@android:color/white"
app:pstsTextAllCaps="true" />
<android.support.v4.view.ViewPager
android:id="@+id/newsPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/newsTabs" />
</RelativeLayout>
</ScrollView>
There was a minor mistake in my code. I changed the
ScrollView
code and its working properly.Just need to add
android:fillViewport="true"
to theScrollView
element. I got the answer from this link: Is it possible to have a ViewPager inside of a ScrollView?