Java Code Examples for android.view.ViewGroup#setClipChildren()

The following examples show how to use android.view.ViewGroup#setClipChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameFragment.java    From memory-game with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	ViewGroup view = (ViewGroup) inflater.inflate(R.layout.game_fragment, container, false);
	view.setClipChildren(false);
	((ViewGroup)view.findViewById(R.id.game_board)).setClipChildren(false);
	mTime = (TextView) view.findViewById(R.id.time_bar_text);
	mTimeImage = (ImageView) view.findViewById(R.id.time_bar_image);
	FontLoader.setTypeface(Shared.context, new TextView[] {mTime}, Font.GROBOLD);
	mBoardView = BoardView.fromXml(getActivity().getApplicationContext(), view);
	FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.game_container);
	frameLayout.addView(mBoardView);
	frameLayout.setClipChildren(false);

	// build board
	buildBoard();
	Shared.eventBus.listen(FlipDownCardsEvent.TYPE, this);
	Shared.eventBus.listen(HidePairCardsEvent.TYPE, this);
	Shared.eventBus.listen(GameWonEvent.TYPE, this);
	
	return view;
}
 
Example 2
Source File: GameFragment.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	ViewGroup view = (ViewGroup) inflater.inflate(R.layout.game_fragment, container, false);
	view.setClipChildren(false);
	((ViewGroup)view.findViewById(R.id.game_board)).setClipChildren(false);
	mTime = (TextView) view.findViewById(R.id.time_bar_text);
	mTimeImage = (ImageView) view.findViewById(R.id.time_bar_image);
	FontLoader.setTypeface(Shared.context, new TextView[] {mTime}, Font.GROBOLD);
	mBoardView = BoardView.fromXml(getActivity().getApplicationContext(), view);
	FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.game_container);
	frameLayout.addView(mBoardView);
	frameLayout.setClipChildren(false);

	// build board
	buildBoard();
	Shared.eventBus.listen(FlipDownCardsEvent.TYPE, this);
	Shared.eventBus.listen(HidePairCardsEvent.TYPE, this);
	Shared.eventBus.listen(GameWonEvent.TYPE, this);
	
	return view;
}
 
Example 3
Source File: FlyoutMenuView.java    From FlyoutMenus with MIT License 5 votes vote down vote up
@Override
protected void onAttachedToWindow() {
	super.onAttachedToWindow();
	if (getParent() != null) {
		ViewGroup v = (ViewGroup) getParent();
		v.setClipChildren(false);
	}
}
 
Example 4
Source File: SwitchButton.java    From MaterialQQLite with Apache License 2.0 5 votes vote down vote up
private void setup() {
	setupBackZone();
	setupSafeZone();
	setupThumbZone();

	setupDrawableBounds();
	if (this.getMeasuredWidth() > 0 && this.getMeasuredHeight() > 0) {
		mSaveLayerZone = new RectF(0, 0, this.getMeasuredWidth(), this.getMeasuredHeight());
	}

	ViewGroup parent = (ViewGroup) this.getParent();
	if (parent != null) {
		parent.setClipChildren(false);
	}
}
 
Example 5
Source File: MainUpView.java    From Android-tv-widget with Apache License 2.0 5 votes vote down vote up
/**
 * 手动添加,不在XML添加的话.
 */
public void attach2Window(Activity activity) {
	ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
	ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	rootView.addView(this, layoutParams);
	rootView.setClipChildren(false);
	rootView.setClipToPadding(false);
}
 
Example 6
Source File: MainUpView.java    From AndroidTVWidget with Apache License 2.0 5 votes vote down vote up
/**
 * 手动添加,不在XML添加的话.
 */
public void attach2Window(Activity activity) {
	ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
	ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	rootView.addView(this, layoutParams);
	rootView.setClipChildren(false);
	rootView.setClipToPadding(false);
}
 
Example 7
Source File: TransitionUtils.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
public static void restoreAncestralClipping(@NonNull View view, List<Boolean> was) {
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        group.setClipChildren(was.remove(0));
    }
    ViewParent parent = view.getParent();
    if (parent != null && parent instanceof ViewGroup) {
        restoreAncestralClipping((ViewGroup) parent, was);
    }
}
 
Example 8
Source File: TransitionUtils.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
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);
    }
    ViewParent parent = view.getParent();
    if (parent != null && parent instanceof ViewGroup) {
        setAncestralClipping((ViewGroup) parent, clipChildren, was);
    }
    return was;
}
 
Example 9
Source File: TabLayout.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void clipViewToPaddingForBadge(boolean flag) {
  // Avoid clipping a badge if it's displayed.
  // Clip children / view to padding when no badge is displayed.
  setClipChildren(flag);
  setClipToPadding(flag);
  ViewGroup parent = (ViewGroup) getParent();
  if (parent != null) {
    parent.setClipChildren(flag);
    parent.setClipToPadding(flag);
  }
}
 
Example 10
Source File: MainUpView.java    From AndroidTvDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 手动添加,不在XML添加的话.
 */
public void attach2Window(Activity activity)
{
    ViewGroup rootView = (ViewGroup)activity.findViewById(Window.ID_ANDROID_CONTENT);
    ViewGroup.LayoutParams layoutParams =
        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rootView.addView(this, layoutParams);
    rootView.setClipChildren(false);
    rootView.setClipToPadding(false);
}
 
Example 11
Source File: ItemConversationAdapter.java    From DragPointView with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    parent.setClipChildren(false);
    parent.setClipToPadding(false);
    if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.item_conversation, null);
        convertView.setTag(new ViewHolder(convertView));
    }
    initializeViews(getItem(position), (ViewHolder) convertView.getTag());
    return convertView;
}
 
Example 12
Source File: TabsWidget.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public TabAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    TabView view = (TabView)LayoutInflater.from(parent.getContext()).inflate(R.layout.tab_view, parent, false);
    parent.setClipToPadding(false);
    parent.setClipChildren(false);
    return new MyViewHolder(view);
}
 
Example 13
Source File: ViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 设置是否限制子 View 在其边界内绘制
 * @param viewGroup    {@link ViewGroup}
 * @param clipChildren {@code true} yes, {@code false} no
 * @return {@code true} success, {@code false} fail
 */
public static boolean setClipChildren(final ViewGroup viewGroup, final boolean clipChildren) {
    if (viewGroup != null) {
        viewGroup.setClipChildren(clipChildren);
        return true;
    }
    return false;
}
 
Example 14
Source File: BoardView.java    From AndroidAnimationExercise with Apache License 2.0 4 votes vote down vote up
private void addTile(final int id, ViewGroup parent) {
	final TileView tileView = TileView.fromXml(getContext(), parent);
	tileView.setLayoutParams(mTileLayoutParams);
	parent.addView(tileView);
	parent.setClipChildren(false);
	mViewReference.put(id, tileView);

	new AsyncTask<Void, Void, Bitmap>() {

		@Override
		protected Bitmap doInBackground(Void... params) {
			return mBoardArrangment.getTileBitmap(id, mSize);
		}

		@Override
		protected void onPostExecute(Bitmap result) {
			tileView.setTileImage(result);
		}
	}.execute();

	tileView.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			if (!mLocked && tileView.isFlippedDown()) {
				tileView.flipUp();
				flippedUp.add(id);
				if (flippedUp.size() == 2) {
					mLocked = true;
				}
				Shared.eventBus.notify(new FlipCardEvent(id));
			}
		}
	});

	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(tileView, "scaleX", 0.8f, 1f);
	scaleXAnimator.setInterpolator(new BounceInterpolator());
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(tileView, "scaleY", 0.8f, 1f);
	scaleYAnimator.setInterpolator(new BounceInterpolator());
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
	animatorSet.setDuration(500);
	tileView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
}
 
Example 15
Source File: TrashView.java    From dingo with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Clear the animation garbage of the target view.
 */
private static void clearClippedChildren(ViewGroup viewGroup) {
    viewGroup.setClipChildren(true);
    viewGroup.invalidate();
    viewGroup.setClipChildren(false);
}
 
Example 16
Source File: TvViewBring.java    From AndroidTvDemo with Apache License 2.0 4 votes vote down vote up
public TvViewBring(ViewGroup vg)
{
    vg.setClipChildren(false);
    vg.setClipToPadding(false);
}
 
Example 17
Source File: WidgetTvViewBring.java    From AndroidTVWidget with Apache License 2.0 4 votes vote down vote up
public WidgetTvViewBring(ViewGroup vg) {
	vg.setClipChildren(false);
	vg.setClipToPadding(false);
	// vg.setChildrenDrawingOrderEnabled(true);
}
 
Example 18
Source File: WidgetTvViewBring.java    From Android-tv-widget with Apache License 2.0 4 votes vote down vote up
public WidgetTvViewBring(ViewGroup vg) {
	vg.setClipChildren(false);
	vg.setClipToPadding(false);
	// vg.setChildrenDrawingOrderEnabled(true);
}
 
Example 19
Source File: BoardView.java    From memory-game with Apache License 2.0 4 votes vote down vote up
private void addTile(final int id, ViewGroup parent) {
	final TileView tileView = TileView.fromXml(getContext(), parent);
	tileView.setLayoutParams(mTileLayoutParams);
	parent.addView(tileView);
	parent.setClipChildren(false);
	mViewReference.put(id, tileView);

	new AsyncTask<Void, Void, Bitmap>() {

		@Override
		protected Bitmap doInBackground(Void... params) {
			return mBoardArrangment.getTileBitmap(id, mSize);
		}
		
		@Override
		protected void onPostExecute(Bitmap result) {
			tileView.setTileImage(result);
		}
	}.execute();
	
	tileView.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			if (!mLocked && tileView.isFlippedDown()) {
				tileView.flipUp();
				flippedUp.add(id);
				if (flippedUp.size() == 2) {
					mLocked = true;
				}
				Shared.eventBus.notify(new FlipCardEvent(id));
			}
		}
	});

	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(tileView, "scaleX", 0.8f, 1f);
	scaleXAnimator.setInterpolator(new BounceInterpolator());
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(tileView, "scaleY", 0.8f, 1f);
	scaleYAnimator.setInterpolator(new BounceInterpolator());
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
	animatorSet.setDuration(500);
	tileView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
}
 
Example 20
Source File: RecordView.java    From RecordView with Apache License 2.0 2 votes vote down vote up
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    View view = View.inflate(context, R.layout.record_view_layout, null);
    addView(view);


    ViewGroup viewGroup = (ViewGroup) view.getParent();
    viewGroup.setClipChildren(false);

    arrow = view.findViewById(R.id.arrow);
    slideToCancel = view.findViewById(R.id.slide_to_cancel);
    smallBlinkingMic = view.findViewById(R.id.glowing_mic);
    counterTime = view.findViewById(R.id.counter_tv);
    basketImg = view.findViewById(R.id.basket_img);
    slideToCancelLayout = view.findViewById(R.id.shimmer_layout);


    hideViews(true);


    if (attrs != null && defStyleAttr == -1 && defStyleRes == -1) {
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RecordView,
                defStyleAttr, defStyleRes);


        int slideArrowResource = typedArray.getResourceId(R.styleable.RecordView_slide_to_cancel_arrow, -1);
        String slideToCancelText = typedArray.getString(R.styleable.RecordView_slide_to_cancel_text);
        int slideMarginRight = (int) typedArray.getDimension(R.styleable.RecordView_slide_to_cancel_margin_right, 30);
        int counterTimeColor = typedArray.getColor(R.styleable.RecordView_counter_time_color, -1);
        int arrowColor = typedArray.getColor(R.styleable.RecordView_slide_to_cancel_arrow_color, -1);


        int cancelBounds = typedArray.getDimensionPixelSize(R.styleable.RecordView_slide_to_cancel_bounds, -1);

        if (cancelBounds != -1)
            setCancelBounds(cancelBounds, false);//don't convert it to pixels since it's already in pixels


        if (slideArrowResource != -1) {
            Drawable slideArrow = AppCompatResources.getDrawable(getContext(), slideArrowResource);
            arrow.setImageDrawable(slideArrow);
        }

        if (slideToCancelText != null)
            slideToCancel.setText(slideToCancelText);

        if (counterTimeColor != -1)
            setCounterTimeColor(counterTimeColor);


        if (arrowColor != -1)
            setSlideToCancelArrowColor(arrowColor);



        setMarginRight(slideMarginRight, true);

        typedArray.recycle();
    }


    animationHelper = new AnimationHelper(context, basketImg, smallBlinkingMic);

}