Skip to content Skip to sidebar Skip to footer

Android Realviewswitcher Shows View Partially

I've got the following problem. I'm using the RealViewSwitcher class (which extends ViewGroup and can be founded here ). I've got three views and swiping between them works well in

Solution 1:

Add the following snippet to your RealViewSwitcher Class,

publicvoidorientationSnapToScreen(Context ctx)
        {
            Displaydisplay= ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
            intdisplayWidth= display.getWidth();

            mNextScreen = Math.max(0, Math.min(getCurrentScreen(), getChildCount() - 1));
            finalintnewX= mNextScreen * displayWidth;
            finalintdelta= newX - getScrollX();

            mScroller.startScroll(getScrollX(), 0, delta, 0, 0);
        }

and add the following method to your main activity from where you are calling the RealViewSwitcher class

@OverridepublicvoidonConfigurationChanged(Configuration newConfig) 
    {
        super.onConfigurationChanged(newConfig);
        realViewSwitcher.orientationSnapToScreen(this);
    }

Post a Comment for "Android Realviewswitcher Shows View Partially"