use of android.view.ViewOutlineProvider in project cardslib by gabrielemariotti.
the class LPreviewUtilsBase method setupCircleButton.
//----------------------------------------------------------------------------
// Circle Button
//----------------------------------------------------------------------------
public void setupCircleButton(ImageButton sourceButton) {
if (hasL()) {
if (sourceButton != null) {
final int size = mActivity.getResources().getDimensionPixelSize(R.dimen.hd_fab_size);
sourceButton.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, size, size);
}
});
sourceButton.setClipToOutline(true);
}
}
}
use of android.view.ViewOutlineProvider in project ListenerMusicPlayer by hefuyicoder.
the class PlayPauseView method onSizeChanged.
@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);
}
}
use of android.view.ViewOutlineProvider in project plaid by nickbutcher.
the class StretchyChangeBounds method createAnimator.
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
final View view = endValues.view;
final ViewGroup parent = ((ViewGroup) view.getParent());
final Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
final Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
// as the captured bounds are in window-space, adjust them to local bounds
int dx = Math.max(view.getLeft(), 0) - endBounds.left;
int dy = Math.max(view.getTop(), 0) - endBounds.top;
startBounds.offset(dx, dy);
endBounds.offset(dx, dy);
// hide the view during the transition and let us draw outside of our bounds
final Drawable background = view.getBackground();
view.setBackground(null);
final ViewOutlineProvider outlineProvider = view.getOutlineProvider();
view.setOutlineProvider(null);
final boolean clipChildren = parent.getClipChildren();
parent.setClipChildren(false);
// use our own drawable in the overlay which we can reposition without thrashing layout
StretchColorDrawable drawable = new StretchColorDrawable(color);
drawable.setBounds(startBounds);
view.getOverlay().add(drawable);
// work out the direction and size change,
// use this to determine which edges are leading vs trailing.
boolean upward = startBounds.centerY() > endBounds.centerY();
boolean expanding = startBounds.width() < endBounds.width();
Interpolator fastOutSlowInInterpolator = AnimUtils.getFastOutSlowInInterpolator(sceneRoot.getContext());
Interpolator slowOutFastInInterpolator = AnimationUtils.loadInterpolator(sceneRoot.getContext(), R.interpolator.slow_out_fast_in);
AnimatorSet transition = new AnimatorSet();
long trailingDuration = calculateTrailingDuration(startBounds, endBounds, sceneRoot.getContext());
Animator leadingEdges, trailingEdges;
if (expanding) {
// expanding, left/right move at speed of leading edge
PropertyValuesHolder left = PropertyValuesHolder.ofInt(StretchColorDrawable.LEFT, startBounds.left, endBounds.left);
PropertyValuesHolder right = PropertyValuesHolder.ofInt(StretchColorDrawable.RIGHT, startBounds.right, endBounds.right);
PropertyValuesHolder leadingEdge = PropertyValuesHolder.ofInt(upward ? StretchColorDrawable.TOP : StretchColorDrawable.BOTTOM, upward ? startBounds.top : startBounds.bottom, upward ? endBounds.top : endBounds.bottom);
leadingEdges = ObjectAnimator.ofPropertyValuesHolder(drawable, left, right, leadingEdge);
leadingEdges.setDuration(leadingDuration);
leadingEdges.setInterpolator(fastOutSlowInInterpolator);
trailingEdges = ObjectAnimator.ofInt(drawable, upward ? StretchColorDrawable.BOTTOM : StretchColorDrawable.TOP, upward ? startBounds.bottom : startBounds.top, upward ? endBounds.bottom : endBounds.top);
trailingEdges.setDuration(trailingDuration);
trailingEdges.setInterpolator(slowOutFastInInterpolator);
} else {
// contracting, left/right move at speed of trailing edge
leadingEdges = ObjectAnimator.ofInt(drawable, upward ? StretchColorDrawable.TOP : StretchColorDrawable.BOTTOM, upward ? startBounds.top : startBounds.bottom, upward ? endBounds.top : endBounds.bottom);
leadingEdges.setDuration(leadingDuration);
leadingEdges.setInterpolator(fastOutSlowInInterpolator);
PropertyValuesHolder left = PropertyValuesHolder.ofInt(StretchColorDrawable.LEFT, startBounds.left, endBounds.left);
PropertyValuesHolder right = PropertyValuesHolder.ofInt(StretchColorDrawable.RIGHT, startBounds.right, endBounds.right);
PropertyValuesHolder trailingEdge = PropertyValuesHolder.ofInt(upward ? StretchColorDrawable.BOTTOM : StretchColorDrawable.TOP, upward ? startBounds.bottom : startBounds.top, upward ? endBounds.bottom : endBounds.top);
trailingEdges = ObjectAnimator.ofPropertyValuesHolder(drawable, left, right, trailingEdge);
trailingEdges.setDuration(trailingDuration);
trailingEdges.setInterpolator(slowOutFastInInterpolator);
}
transition.playTogether(leadingEdges, trailingEdges);
transition.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// clean up
parent.setClipChildren(clipChildren);
view.setBackground(background);
view.setOutlineProvider(outlineProvider);
view.getOverlay().clear();
}
});
return transition;
}
use of android.view.ViewOutlineProvider in project google-io-2014 by romainguy.
the class DetailActivity method setOutlines.
private void setOutlines(int star, int info) {
final int size = getResources().getDimensionPixelSize(R.dimen.floating_button_size);
final ViewOutlineProvider vop = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, size, size);
}
};
findViewById(star).setOutlineProvider(vop);
findViewById(info).setOutlineProvider(vop);
}
use of android.view.ViewOutlineProvider in project FloatingActionButton by Clans.
the class Label method createFillDrawable.
@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;
}
Aggregations