类android.view.ViewOutlineProvider源码实例Demo

下面列出了怎么用android.view.ViewOutlineProvider的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Carbon   文件: DrawerLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码2 项目: abelana   文件: FloatingActionButton.java
/**
 * Constructor.
 * @param context the application context.
 * @param attrs attributes.
 * @param defStyleAttr attribute in the current theme that contains a
 *                     reference to a style resource that supplies defaults
 *                     values for the StyledAttributes
 * @param defStyleRes a resource identifier of a style resource that
 *                    supplies default values for the StyledAttributes,
 *                    used only if defStyleAttr is 0 or can not be found
 *                    in the theme
 */
public FloatingActionButton(Context context, AttributeSet attrs,
                            int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr);

    setClickable(true);

    // Set the outline provider for this view. The provider is given the
    // outline which it can then modify as needed. In this case we set the
    // outline to be an oval fitting the height and width.
    setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            outline.setOval(0, 0, getWidth(), getHeight());
        }
    });

    // Finally, enable clipping to the outline, using the provider we set
    // above
    setClipToOutline(true);
}
 
源代码3 项目: AndroidNavigation   文件: TabBar.java
private void init(Context context) {
    selectedItemColor = AppUtils.fetchContextColor(context, R.attr.colorAccent);
    unselectedItemColor = Color.LTGRAY;
    barBackgroundColor = Color.WHITE;
    badgeColor = Color.parseColor("#FF3B30");

    setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)));
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View parentView = inflater.inflate(R.layout.nav_tab_bar_container, this, true);
    container = parentView.findViewById(R.id.nav_tab_bar_container);
    tabContainer = parentView.findViewById(R.id.nav_tab_bar_item_container);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        this.setOutlineProvider(ViewOutlineProvider.BOUNDS);
    }

    ViewCompat.setElevation(this, 0);
    setClipToPadding(false);
}
 
源代码4 项目: ShapeOfView   文件: ShapeOfView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ViewOutlineProvider getOutlineProvider() {
    return new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            if (clipManager != null && !isInEditMode()) {
                final Path shadowConvexPath = clipManager.getShadowConvexPath();
                if (shadowConvexPath != null) {
                    try {
                        outline.setConvexPath(shadowConvexPath);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }

        }
    };
}
 
源代码5 项目: JellyRefreshLayout   文件: JellyLayout.java
private void init() {
    setWillNotDraw(false);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);

    mPath = new Path();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mViewOutlineProvider = new ViewOutlineProvider() {
            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                if (mPath.isConvex()) outline.setConvexPath(mPath);
            }
        };

    }
}
 
源代码6 项目: Carbon   文件: MotionLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码7 项目: HaoReader   文件: AudioPlayingButton.java
private void initView() {
    ViewCompat.setElevation(this, DensityUtil.dp2px(getContext(), 8));
    ViewCompat.setBackground(this, getResources().getDrawable(R.drawable.shape_audio_bar));
    setOutlineProvider(ViewOutlineProvider.BACKGROUND);


    ivCover.setOnClickListener(this::startPlayerActivity);

    btnPause.setOnClickListener(v -> startPlayerActivity(ivCover));

    final OnLongClickListener longClickListener = v -> {
        AudioBookPlayService.stop(getContext());
        return true;
    };

    ivCover.setOnLongClickListener(longClickListener);
    btnPause.setOnLongClickListener(longClickListener);
}
 
源代码8 项目: Carbon   文件: ConstraintLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码9 项目: LaunchEnr   文件: HeaderElevationController.java
HeaderElevationController(View header) {
    mHeader = header;
    final Resources res = mHeader.getContext().getResources();
    mMaxElevation = res.getDimension(R.dimen.all_apps_header_max_elevation);
    mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);

    // We need to provide a custom outline so the shadow only appears on the bottom edge.
    // The top, left and right edges are all extended out, and the shadow is clipped
    // by the parent.
    final ViewOutlineProvider vop = new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            final View parent = (View) mHeader.getParent();

            final int left = parent.getLeft(); // Use the parent to account for offsets
            final int top = view.getTop();
            final int right = left + view.getWidth();
            final int bottom = view.getBottom();

            final int offset = Utilities.pxFromDp(mMaxElevation, res.getDisplayMetrics());
            outline.setRect(left - offset, top - offset, right + offset, bottom);
        }
    };
    mHeader.setOutlineProvider(vop);
}
 
源代码10 项目: Carbon   文件: AppBarLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码11 项目: Carbon   文件: LinearLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码12 项目: DMAudioStreamer   文件: PlayPauseView.java
@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mDrawable.setBounds(0, 0, w, h);
    mWidth = w;
    mHeight = h;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(new ViewOutlineProvider() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
    }
}
 
源代码13 项目: JD-Test   文件: BottomNavigationBar.java
/**
     * This method initiates the bottomNavigationBar and handles layout related values
     */
    private void init() {

//        MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_padded_height)));
//        marginParams.setMargins(0, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_top_margin_correction), 0, 0);

        setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)));

        LayoutInflater inflater = LayoutInflater.from(getContext());
        View parentView = inflater.inflate(R.layout.bottom_navigation_bar_container, this, true);
        mBackgroundOverlay = (FrameLayout) parentView.findViewById(R.id.bottom_navigation_bar_overLay);
        mContainer = (FrameLayout) parentView.findViewById(R.id.bottom_navigation_bar_container);
        mTabContainer = (LinearLayout) parentView.findViewById(R.id.bottom_navigation_bar_item_container);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.setOutlineProvider(ViewOutlineProvider.BOUNDS);
        } else {
            //to do
        }

        ViewCompat.setElevation(this, mElevation);
        setClipToPadding(false);
    }
 
源代码14 项目: Carbon   文件: CollapsingToolbarLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码15 项目: Oblique   文件: ObliqueView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ViewOutlineProvider getOutlineProvider() {
    shadowpath = new Path();
    if (config.getRadius() == 0) {
        shadowpath = path;
    } else {
        rect = new Rect(0, 0, (int) width, (int) height);
        RectF r = new RectF(rect);
        shadowpath.addRoundRect(r, config.getRadius(), config.getRadius(), Path.Direction.CCW);
        shadowpath.op(path, shadowpath, Path.Op.INTERSECT);
    }
    return new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            if (path.isConvex()) {
                outline.setConvexPath(shadowpath);
            }
        }
    };
}
 
源代码16 项目: FluxyAndroidTodo   文件: FloatingActionButton.java
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr,
                            int defStyleRes) {
    super(context, attrs, defStyleAttr);

    setClickable(true);

    // Set the outline provider for this view. The provider is given the outline which it can
    // then modify as needed. In this case we set the outline to be an oval fitting the height
    // and width.
    setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            outline.setOval(0, 0, getWidth(), getHeight());
        }
    });

    // Finally, enable clipping to the outline, using the provider we set above
    setClipToOutline(true);
}
 
源代码17 项目: ShareBox   文件: FloatingActionButton.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{-android.R.attr.state_enabled}, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[]{android.R.attr.state_pressed}, createCircleDrawable(mColorPressed));
    drawable.addState(new int[]{}, createCircleDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
源代码18 项目: ShareBox   文件: Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{android.R.attr.state_pressed}, createRectDrawable(mColorPressed));
    drawable.addState(new int[]{}, createRectDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
源代码19 项目: Carbon   文件: Button.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码20 项目: Carbon   文件: ImageView.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码21 项目: GeometricWeather   文件: TagView.java
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    outline.set(0, 0, getMeasuredWidth(), getMeasuredHeight());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline viewOutline) {
                viewOutline.setRoundRect(
                        (int) outline.left,
                        (int) outline.top,
                        (int) outline.right,
                        (int) outline.bottom,
                        outline.height() / 2
                );
            }
        });
    }
}
 
源代码22 项目: GeometricWeather   文件: PrecipitationBar.java
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRoundRect(
                        0,
                        0,
                        view.getMeasuredWidth(),
                        view.getMeasuredHeight(),
                        view.getMeasuredHeight() / 2f
                );
            }
        });
    }
}
 
源代码23 项目: Carbon   文件: TextView.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码24 项目: material-components-android   文件: Chip.java
private void initOutlineProvider() {
  if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
    setOutlineProvider(
        new ViewOutlineProvider() {
          @Override
          @TargetApi(Build.VERSION_CODES.LOLLIPOP)
          public void getOutline(View view, @NonNull Outline outline) {
            if (chipDrawable != null) {
              chipDrawable.getOutline(outline);
            } else {
              outline.setAlpha(0.0f);
            }
          }
        });
  }
}
 
源代码25 项目: Carbon   文件: FlowLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码26 项目: Mysplash   文件: CircularImageView.java
private void initialize() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(new ViewOutlineProvider() {
            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(
                        view.getPaddingLeft(),
                        view.getPaddingTop(),
                        view.getWidth() - view.getPaddingRight(),
                        view.getHeight() - view.getPaddingBottom()
                );
            }
        });
        setClipToOutline(true);
    }
}
 
源代码27 项目: Carbon   文件: GridLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码28 项目: Carbon   文件: FrameLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
源代码29 项目: BottomNavigation   文件: BottomNavigationBar.java
/**
     * This method initiates the bottomNavigationBar and handles layout related values
     */
    private void init() {

//        MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_padded_height)));
//        marginParams.setMargins(0, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_top_margin_correction), 0, 0);

        setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)));

        LayoutInflater inflater = LayoutInflater.from(getContext());
        View parentView = inflater.inflate(R.layout.bottom_navigation_bar_container, this, true);
        mBackgroundOverlay = parentView.findViewById(R.id.bottom_navigation_bar_overLay);
        mContainer = parentView.findViewById(R.id.bottom_navigation_bar_container);
        mTabContainer = parentView.findViewById(R.id.bottom_navigation_bar_item_container);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.setOutlineProvider(ViewOutlineProvider.BOUNDS);
        } else {
            //to do
        }

        ViewCompat.setElevation(this, mElevation);
        setClipToPadding(false);
    }
 
源代码30 项目: Carbon   文件: RelativeLayout.java
private void updateCorners() {
    if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
        setClipToOutline(true);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Carbon.isShapeRect(shapeModel, boundsRect)) {
                    outline.setRect(0, 0, getWidth(), getHeight());
                } else {
                    shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
                    shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);
                    shadowDrawable.getOutline(outline);
                }
            }
        });
    }

    boundsRect.set(shadowDrawable.getBounds());
    shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask);
}
 
 类所在包
 类方法
 同包方法