how to make map overlap layout in view pager

前端 未结 1 875
眼角桃花
眼角桃花 2021-01-06 04:28

i have nested fragment that contain mapview, all views are overlapping as i expected except mapview. i have a recyclerview too.. that display under the cut layout, but map

1条回答
  •  执笔经年
    2021-01-06 05:02

    user cut layout instead of RelativeLayout

    public class CutLayout extends FrameLayout {
        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        private Xfermode pdMode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);
        private Path path = new Path();
    
        public CutLayout(Context context) {
            super(context);
        }
    
        public CutLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public CutLayout(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }
    
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        public CutLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
        }
    
        @Override
        protected void dispatchDraw(Canvas canvas) {
            int saveCount = canvas.saveLayer(0, 0, getWidth(), getHeight(), null, Canvas.ALL_SAVE_FLAG);
            super.dispatchDraw(canvas);
    
            paint.setXfermode(pdMode);
            path.reset();
    
            path.moveTo(0, getHeight());
            path.lineTo(getWidth(), getHeight());
            path.lineTo(getWidth(), getHeight() - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, getResources().getDisplayMetrics()));
            path.close();
            canvas.drawPath(path, paint);
    
            canvas.restoreToCount(saveCount);
            paint.setXfermode(null);
        } }
    

    and in xml file

    
    
            
    
    

    0 讨论(0)
提交回复
热议问题