1

I have little problem with viewPager. I have ViewPager with 4 frgaments which displayed RoundedImageView. The RoundedImageView has a rounded corners. When I was swiped from right to left then a corners is not rounded. That look like this:

Default Swipe left-to-right

I set white rounded backgorund for viewpager. When I not displayed a RoundedImageView(is hide) then all is ok and I have always rounded background in view pager.

I tried set clipChildren and I failed. I don't have idea to resolve my problem.

[EDIT:]

I have another problem with RoundedClipingLayout: W/OpenGLRenderer﹕ Bitmap too large to be uploaded into a texture (1726620832x0, max=4096x4096)

Community
  • 1
  • 1
Michael
  • 780
  • 1
  • 10
  • 34
  • That was help me. https://github.com/venator85/RoundClippingLayout/blob/master/src/com/example/roundclippinglayout/RoundClippingLinearLayout.java – Michael Aug 17 '15 at 11:39
  • When you show the RoundClippingLayout, background RoundClippingLayout is not visible ? Is this is your problem ? – umerk44 Aug 18 '15 at 07:03
  • When I use RoundClippingLayout then I gets problem: Bitmap too large to be uploaded into a texture. This is my problem i now. – Michael Aug 18 '15 at 07:38
  • This is a very known issue in android check this link http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object – umerk44 Aug 18 '15 at 08:20
  • Sorry that now help for me. I have in side RoundClippingLayout imageView and few LinearLayout(+ TextViews). I would like to clipping all views in side roundClippingLayouts – Michael Aug 18 '15 at 10:54

1 Answers1

0

I use this solution. If somebody want to check or use:

public class RoundClippingLinearLayout extends LinearLayout {
    private RectF rect;
    private int mCornerRadius = 10;

    public RoundClippingLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        onInit();
    }

    public RoundClippingLinearLayout(Context context) {
        super(context);
        onInit();
    }

    protected void onInit() {
        mCornerRadius = getResources().getDimensionPixelOffset(R.dimen.radius);

        setWillNotDraw(false);
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if (w != oldw && h != oldh) {
            rect = new RectF(0, 0, w, h);
        }
    }


    @Override
    protected void dispatchDraw(Canvas canvas) {
        canvas.setDrawFilter(new PaintFlagsDrawFilter(1, Paint.ANTI_ALIAS_FLAG));

        Path clipPath = new Path();
        clipPath.addRoundRect(rect, mCornerRadius, mCornerRadius, Path.Direction.CW);
        canvas.clipPath(clipPath);

        super.dispatchDraw(canvas);
    }
}
Michael
  • 780
  • 1
  • 10
  • 34