Android Viewpager Padding/Margin Between Page Fragments

How to set padding between ViewPager pages while keeping the page full-width

It seems that more recent releases of the support package (since revision 5) have added support for margins between pages of ViewPager via setPageMargin() and setPageMarginDrawable().

How to show viewpager with margin or different design

Try Change margin to padding

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:paddingLeft="40dp"
android:paddingRight="40dp"
tools:context="com.tpayerapp.Fragments.PayPalFragment">

<ImageView
android:id="@+id/imageView25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="false"
android:layout_centerInParent="true"
android:background="@color/colorAccent"
app:srcCompat="@drawable/paypal" />

How to set margin with ViewPager filling the parent

I guess the layout with the rounded corners is the layout your viewpager calls, try to create a linearlayout inside your current layout and add the margins inside this one.
I hope this helps you, or it may inspire you a solution.

How to remove the space between two fragments in android view pager?

hey this code helps you :)

final int pageMargin = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources() .getDisplayMetrics());
viewPager.setPageMargin(pageMargin);


Related Topics



Leave a reply



Submit