Insert Separator Between View-pager
How could i insert some padding between the pages inside view-pager like in the market app - the black line
Solution 1:
This worked for me. I just set the margin and filled it with a color.
viewPager.setPageMargin(20); // TODO Convert 'px' to 'dp'
viewPager.setPageMarginDrawable(R.color.black);
EDIT: To convert dp to pixel conversion I used:
int px = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()));
mViewPager.setPageMargin(px);
mViewPager.setPageMarginDrawable(R.color.black);
Solution 2:
That is a new api for the ViewPager
called the margin, a link to it can be found setPageMargin()
. Make sure you are using the latest support library.
Solution 3:
Use This method:
publicvoidsetPageMarginDrawable(int resId)
You will be able to set a drawable that will be used to fill the margin between pages.
Post a Comment for "Insert Separator Between View-pager"