use of android.view.ViewOutlineProvider in project RxTools by vondear.
the class RxPopupViewManager method setTipViewElevation.
private void setTipViewElevation(TextView tipView, RxPopupView rxPopupView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (rxPopupView.getElevation() > 0) {
ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setEmpty();
}
};
tipView.setOutlineProvider(viewOutlineProvider);
tipView.setElevation(rxPopupView.getElevation());
}
}
}
use of android.view.ViewOutlineProvider in project android_frameworks_base by ResurrectionRemix.
the class TaskCardView method setAsScreenShotView.
private void setAsScreenShotView(Bitmap screenshot, ImageView screenshotView) {
LayoutParams lp = (LayoutParams) screenshotView.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
screenshotView.setLayoutParams(lp);
screenshotView.setClipToOutline(true);
screenshotView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mCornerRadius);
}
});
screenshotView.setImageBitmap(screenshot);
}
use of android.view.ViewOutlineProvider in project KL2 by jweihao.
the class ClippingActivity method onViewClicked.
@OnClick({ R.id.tv_rect, R.id.tv_circle })
public void onViewClicked(View view) {
switch(view.getId()) {
case R.id.tv_rect:
// 获取Outline
ViewOutlineProvider rect = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
// 修改outline为特定形状
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 30);
}
};
// 重新设置形状
mTvRect.setOutlineProvider(rect);
break;
case R.id.tv_circle:
// 获取Outline
ViewOutlineProvider circle = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
// 修改outline为特定形状
outline.setOval(0, 0, view.getWidth(), view.getHeight());
}
};
// 重新设置形状
mTvCircle.setOutlineProvider(circle);
break;
default:
break;
}
}
use of android.view.ViewOutlineProvider in project android_packages_apps_Dialer by MoKee.
the class CircularRevealFragment method startOutgoingAnimation.
public void startOutgoingAnimation(MaterialPalette palette) {
final Activity activity = getActivity();
if (activity == null) {
Log.w(this, "Asked to do outgoing call animation when not attached");
return;
}
final View view = activity.getWindow().getDecorView();
// The circle starts from an initial size of 0 so clip it such that it is invisible.
// Otherwise the first frame is drawn with a fully opaque screen which causes jank. When
// the animation later starts, this clip will be clobbered by the circular reveal clip.
// See ViewAnimationUtils.createCircularReveal.
view.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
// Using (0, 0, 0, 0) will not work since the outline will simply be treated as
// an empty outline.
outline.setOval(-1, -1, 0, 0);
}
});
view.setClipToOutline(true);
if (palette != null) {
view.findViewById(R.id.outgoing_call_animation_circle).setBackgroundColor(palette.mPrimaryColor);
activity.getWindow().setStatusBarColor(palette.mSecondaryColor);
activity.getWindow().setNavigationBarColor(palette.mSecondaryColor);
}
view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mAnimationFinished = false;
final ViewTreeObserver vto = view.getViewTreeObserver();
if (vto.isAlive()) {
vto.removeOnPreDrawListener(this);
}
final Animator animator = getRevealAnimator(mTouchPoint);
if (animator != null) {
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
Log.w(TAG, " CircularRevealFragment - onAnimationEnd");
view.setClipToOutline(false);
if (mListener != null && mAnimationFinished == false) {
mListener.onCircularRevealComplete(getFragmentManager());
mAnimationFinished = true;
}
}
});
animator.start();
// If somehow the animator is failed to run from lower layers,
// need to wait for certain expiration time and inform the
// listeners with OnCircularComplete callback so that rest of
// the things will not be blocked.
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Log.w(TAG, " Failed to complete animation");
if (mListener != null && mAnimationFinished == false) {
mListener.onCircularRevealComplete(getFragmentManager());
mAnimationFinished = true;
}
}
}, getResources().getInteger(R.integer.reveal_animation_duration) + REVEAL_ADDITIONAL_EXPIRATION_TIME);
}
return false;
}
});
}
use of android.view.ViewOutlineProvider in project ChatExchange by HueToYou.
the class FloatingActionButton method createFillDrawable.
@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;
}
Aggregations