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

The following examples show how to use android.view.ViewGroup#setClipChildren() . These examples are extracted from open source projects. 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
@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 Project: memory-game   File: GameFragment.java    License: 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 Project: DevUtils   File: ViewUtils.java    License: 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 4
@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 5
@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 6
Source Project: AndroidTvDemo   File: MainUpView.java    License: 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
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 8
Source Project: FlyoutMenus   File: FlyoutMenuView.java    License: 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 9
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 10
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 11
Source Project: AndroidTVWidget   File: MainUpView.java    License: 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 12
Source Project: Android-tv-widget   File: MainUpView.java    License: 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 13
Source Project: MaterialQQLite   File: SwitchButton.java    License: 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 14
Source Project: dingo   File: TrashView.java    License: 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 15
Source Project: AndroidTvDemo   File: TvViewBring.java    License: Apache License 2.0 4 votes vote down vote up
public TvViewBring(ViewGroup vg)
{
    vg.setClipChildren(false);
    vg.setClipToPadding(false);
}
 
Example 16
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 17
public WidgetTvViewBring(ViewGroup vg) {
	vg.setClipChildren(false);
	vg.setClipToPadding(false);
	// vg.setChildrenDrawingOrderEnabled(true);
}
 
Example 18
public WidgetTvViewBring(ViewGroup vg) {
	vg.setClipChildren(false);
	vg.setClipToPadding(false);
	// vg.setChildrenDrawingOrderEnabled(true);
}
 
Example 19
Source Project: memory-game   File: BoardView.java    License: 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 Project: RecordView   File: RecordView.java    License: 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);

}