List of usage examples for android.graphics.drawable ClipDrawable setLevel
public final boolean setLevel(@IntRange(from = 0, to = 10000) int level)
From source file:Main.java
@SuppressWarnings("deprecation") public static void clipDrawable(final View image, Drawable drawable, boolean isActivated) { if (drawable == null) { return;/*from w ww.j av a2 s. c o m*/ } if (isActivated) { final ClipDrawable scaleDrawable = new ClipDrawable(drawable, Gravity.CENTER, ClipDrawable.HORIZONTAL | ClipDrawable.VERTICAL); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { image.setBackground(scaleDrawable); } else { image.setBackgroundDrawable(scaleDrawable); } image.setBackgroundDrawable(scaleDrawable); ValueAnimator animator = ValueAnimator.ofInt(0, 10000); animator.setDuration(200); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleDrawable.setLevel((Integer) animation.getAnimatedValue()); } }); animator.start(); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { image.setBackground(null); } else { image.setBackgroundDrawable(null); } } }
From source file:com.bitants.wally.views.swipeclearlayout.SwipeClearLayout.java
private void setTargetOffsetTopAndBottom(int offset) { circle.offsetTopAndBottom(offset);/* ww w . j a v a 2 s .c om*/ currentTargetOffsetTop = circle.getTop(); int percent = (int) ((currentTargetOffsetTop / distanceToTriggerSync) * 100); if (onSwipeListener != null) { onSwipeListener.onSwipe(percent, currentTargetOffsetTop); } ViewCompat.setElevation(circle, percent); ImageView imageView = (ImageView) circle; ClipDrawable clipDrawable = (ClipDrawable) imageView.getDrawable(); if (percent < 50) { clipDrawable.setLevel(0); } else { clipDrawable.setLevel((percent - 50) * 2 * 100); } }
From source file:org.cyanogenmod.theme.chooser.ChooserDetailFragment.java
private void refreshApplyButton() { //Default//w ww . j a va 2 s . c o m mApply.setText(R.string.apply); StateListDrawable d = (StateListDrawable) mApply.getBackground(); LayerDrawable bg = (LayerDrawable) d .getStateDrawable(d.getStateDrawableIndex(new int[] { android.R.attr.state_enabled })); final ClipDrawable clip = (ClipDrawable) bg.findDrawableByLayerId(android.R.id.progress); clip.setLevel(0); //Determine whether the apply button should show "apply" or "update" if (mAppliedThemeCursor != null) { mAppliedThemeCursor.moveToPosition(-1); while (mAppliedThemeCursor.moveToNext()) { String component = mAppliedThemeCursor .getString(mAppliedThemeCursor.getColumnIndex(MixnMatchColumns.COL_KEY)); String pkg = mAppliedThemeCursor .getString(mAppliedThemeCursor.getColumnIndex(MixnMatchColumns.COL_VALUE)); // At least one component is set here for this theme if (pkg != null && mPkgName.equals(pkg)) { mApply.setText(R.string.update); break; } } } //Determine if the apply button's progress int progress = (mService == null) ? 0 : mService.getProgress(); if (progress != 0) { clip.setLevel(progress * 100); mApply.setText(R.string.applying); mApply.setClickable(false); } else { mApply.setClickable(true); } }