0

this below screen shot is Gmail viewpager which that implemented outline borders for viewpager Fragments

swipe from left to right

enter image description here

swipe from right to left

enter image description here

And now i want to implementing that for my application but can design that:

swipe from left to right

enter image description here

swipe from right to left

enter image description here

My root layout xml is:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="-15dp"
    android:layout_marginRight="-30dp"
    android:background="#949494"
    android:paddingLeft="-15dp"
    android:paddingRight="-15dp">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="30dp"
        android:background="#ffffff">

        ...

    </FrameLayout>

</FrameLayout>
mahdi pishguy
  • 994
  • 1
  • 14
  • 43

2 Answers2

1

Perhaps you want something like this? insert separator between view-pager

You can use a margin drawable to reproduce the style.

Community
  • 1
  • 1
Mdlc
  • 7,128
  • 12
  • 55
  • 98
0

My solution to implementing viewpager like with Gmail

Result:

enter image description here

viewPager root layout:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#d1d1d1">
    <android.support.v4.view.ViewPager
        android:id="@+id/vp_horizontal_ntb"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="-25dp"
        android:layout_marginRight="-25dp"
        android:layout_marginTop="30dp"/>

fragment layout:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="-20dp"
    android:layout_marginRight="-20dp"
    android:background="#eeeeee">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="#ffffff">
    </FrameLayout>

</FrameLayout>

and setPageMargin:

viewPager.setPageMargin(80);
mahdi pishguy
  • 994
  • 1
  • 14
  • 43