A ViewPager
adds its children(the pages) through it's adapter, you shouldn't add the child views directly in the xml layout as you did. So, keep the initial layout with only the ViewPager
:
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content" />
create a new xml layout with the content of the page(like page.xml
):
<LinearLayout
android:id="@+id/ll_filter_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.edmodo.rangebar.RangeBar
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/rangebar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
custom:tickCount="2000"
custom:tickHeight="0dp" />
</LinearLayout>
and wire this up in the adapter by getting a reference to a LayoutInflater
(either pass it to the adapter directly or create it from a Context
)and then using that to inflate the above page.xml
layout according to your position.