Back to project page CustomViewPager.
The source code is released under:
Apache License
If you think the Android project CustomViewPager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kgnkbyl.custompager; // w ww . j a va 2s.c om import android.content.Context; import android.graphics.Point; import android.view.Display; import android.view.WindowManager; public class HelperClass { private static Point screenSize; public static int getWindowWidth(Context context){ if(screenSize == null){ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); screenSize = new Point(); display.getSize(screenSize); } if(screenSize != null) return screenSize.x; else return 0; } public static int getWindowHeight(Context context){ if(screenSize == null){ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); screenSize = new Point(); display.getSize(screenSize); } if(screenSize != null) return screenSize.y; else return 0; } public static int getCurrentCardPositionX(Context context){ float cardWidth = context.getResources().getDimension(R.dimen.card_image_width); return (int) (getWindowWidth(context)/2 - cardWidth/2); } }