Skip to content Skip to sidebar Skip to footer

Swiping The Pages With Viewpage

I'm trying to fill the page by blocks of linearlayout by data. Also I'm using ViewPager for changing pages. Every page should have its own data blocks, but now I'm getting linearla

Solution 1:

Your problem is that you are using RelativeLayouts, and since you are not aligning its children elements(ViewPager and LinearLayout), they are overlapping:

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns: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"tools:context=".MyActivity"><android.support.v4.view.ViewPagerandroid:id="@+id/page"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true" /><LinearLayoutandroid:orientation="vertical"android:id="@+id/page_blocks"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/page" ></LinearLayout>

This line tells the viewpager that its position is going to be at the top of the RelativeLayout:

android:layout_alignParentTop="true"

And this one tells the LinearLayout its position is below the viewpager:

android:layout_below="@id/page"

There are some other properties that can be set --> RelativeLayout

To be honest, I'm not sure what you are trying to do. But maybe you just need to get rid of the RelativeLayout and use LinearLayouts instead.

Post a Comment for "Swiping The Pages With Viewpage"