Search code examples
androidandroid-layoutandroid-viewpagerandroid-tabs

How to achieve a custom layout with next page title shown half, indicating the user of next page as shown in android


FIRST PAGE IMG[/IMG]

SECOND PAGE IMG[/IMG]

I want show my two pages like this, When loading first page the second page title should be shown indicating the user about a second page. How can I achieve this?, I can put two tabs or viewpager with view pager indicator, i want that functionality but actually what I ask here is the view that is marked the image, the next tab to display half of its title indicating the user of next page.

Thanks in advance..


Solution

  • You can directly use ViewPager with PagerTabStrip provided in android support-v4 library. Download android Support-V4 library here

    Then extract the android Support-V4 jar and paste into your project libs Folder. Right click and Add to build path.

    Now use View pager with PagerTabStrip in your Main layout as:

    main.xml

    <?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" >  
    
        <android.support.v4.view.ViewPager  
            android:id="@+id/viewpage"  
            android:layout_width="match_parent"  
            android:layout_height="match_parent"
            android:layout_below="@+id/pagetab"
             >  
    
            <android.support.v4.view.PagerTabStrip  
            android:id="@+id/pagetab"  
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content" 
            android:textColor="#333333"
            android:background="#ffffff" 
            android:layout_gravity="top"/>  
    
        </android.support.v4.view.ViewPager>  
    
    </RelativeLayout>
    

    Now populate the ViewPager using Adapter in Main Class .see here

    Now you can Achieve What you want.