Example usage for android.view ViewGroup setClipChildren

List of usage examples for android.view ViewGroup setClipChildren

Introduction

In this page you can find the example usage for android.view ViewGroup setClipChildren.

Prototype

public void setClipChildren(boolean clipChildren) 

Source Link

Document

By default, children are clipped to their bounds before drawing.

Usage

From source file:Main.java

public static void disableParentsClip(@NonNull View view) {
    while (view.getParent() != null && view.getParent() instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view.getParent();
        viewGroup.setClipChildren(false);
        viewGroup.setClipToPadding(false);
        view = viewGroup;//from   w ww .  j  a va  2  s  . co  m
    }
}

From source file:Main.java

public static void restoreAncestralClipping(@NonNull View view, List<Boolean> was) {
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        group.setClipChildren(was.remove(0));
    }//from   www  .j  a va 2  s.c  o  m
    ViewParent parent = view.getParent();
    if (parent != null && parent instanceof ViewGroup) {
        restoreAncestralClipping((ViewGroup) parent, was);
    }
}

From source file:Main.java

private static List<Boolean> setAncestralClipping(@NonNull View view, boolean clipChildren, List<Boolean> was) {
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        was.add(group.getClipChildren());
        group.setClipChildren(clipChildren);
    }/*w  w w.  java 2  s  .  co  m*/
    ViewParent parent = view.getParent();
    if (parent != null && parent instanceof ViewGroup) {
        setAncestralClipping((ViewGroup) parent, clipChildren, was);
    }
    return was;
}

From source file:com.tiancaicc.springfloatingactionmenu.MenuItemView.java

private void init(Context context, boolean hasMargin) {

    Resources resources = getResources();
    int diameterPX = Utils.dpToPx(mMenuItem.getDiameter(), resources);
    this.mDiameter = diameterPX;
    mBtn = new ImageButton(context);
    mBtn.setScaleType(ImageView.ScaleType.FIT_CENTER);
    if (hasMargin) {
        int p = Util.dpToPx(12, getResources());
        mBtn.setPadding(p, p, p, p);/*ww  w.j  a v  a  2 s .  co m*/
    }
    LayoutParams btnLp = new LayoutParams(diameterPX, diameterPX);
    btnLp.gravity = Gravity.CENTER_HORIZONTAL;
    btnLp.bottomMargin = Util.dpToPx(mGapSize, resources);
    mBtn.setLayoutParams(btnLp);
    OvalShape ovalShape = new OvalShape();
    ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
    shapeDrawable.getPaint().setColor(resources.getColor(mMenuItem.getBgColor()));
    mBtn.setBackgroundDrawable(shapeDrawable);
    if (TextUtils.isEmpty(mMenuItem.getIconFilePath())) {
        mBtn.setImageResource(mMenuItem.getIcon());
    } else {
        mBtn.setImageURI(Uri.fromFile(new File(mMenuItem.getIconFilePath())));
    }
    mBtn.setClickable(false);
    addView(mBtn);

    mLabel = (com.github.omadahealth.typefaceview.TypefaceTextView) View.inflate(getContext(),
            R.layout.c_text_view, null);
    mLabel.setPaintFlags(mLabel.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    mLabel.setTextIsSelectable(false);
    LayoutParams labelLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    labelLp.gravity = Gravity.CENTER_HORIZONTAL;
    mLabel.setLayoutParams(labelLp);
    if (!TextUtils.isEmpty(mMenuItem.getLabel())) {
        mLabel.setPadding(0, Util.dpToPx(70, getResources()), 0, 0);
        Drawable bottomArrow = ContextCompat.getDrawable(getContext(), R.drawable.ic_arrow);
        mLabel.setCompoundDrawablesWithIntrinsicBounds(null, null, null, bottomArrow);
    }
    mLabel.setText(mMenuItem.getLabel());
    mLabel.setTextColor(resources.getColor(mMenuItem.getTextColor()));
    //        mLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize);
    addView(mLabel);

    setOrientation(LinearLayout.VERTICAL);
    if (mAlphaAnimation) {
        setAlpha(0);
    }

    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            getViewTreeObserver().removeGlobalOnLayoutListener(this);
            applyPressAnimation();
            ViewGroup parent = (ViewGroup) getParent();
            parent.setClipChildren(false);
            parent.setClipToPadding(false);
            setClipChildren(false);
            setClipToPadding(false);
        }
    });

}

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

private void setAncestorsShouldClipChildren(boolean clip) {
    if (!isLocationBarShownInNTP())
        return;/*from   w  w w. j  av a  2  s  .  co  m*/
    ViewGroup parent = this;
    while (parent != null) {
        parent.setClipChildren(clip);
        if (!(parent.getParent() instanceof ViewGroup))
            break;
        if (parent.getId() == android.R.id.content)
            break;
        parent = (ViewGroup) parent.getParent();
    }
}