@Override public void onAnimationUpdate(ValueAnimator animation) { // TODO: some way to auto-invalidate views based on drawable changes? callbacks? view.invalidate(startDrawable.getBounds()); } });
@Override public void onAnimationUpdate(ValueAnimator animation) { // TODO: some way to auto-invalidate views based on drawable changes? callbacks? view.invalidate(startDrawable.getBounds()); } });
@Test public void mutate_createsDeepCopy() throws Exception { BitmapDrawable original = (BitmapDrawable) resources.getDrawable(R.drawable.an_image); Drawable mutated = original.mutate(); assertThat(original).isNotSameAs(mutated); assertThat(mutated instanceof BitmapDrawable).isTrue(); assertThat(mutated.getIntrinsicHeight()).isEqualTo(original.getIntrinsicHeight()); assertThat(mutated.getIntrinsicWidth()).isEqualTo(original.getIntrinsicWidth()); assertThat(mutated.getBounds()).isEqualTo(original.getBounds()); }
public Rect getBounds() { return mDefaultStateBitmap.getBounds(); }
public Rect getBounds() { return mDefaultStateBitmap.getBounds(); }
public Rect getBounds() { return mOuterBitmap.getBounds(); }
public int getIntrinsicWidth() { return this.drawable == null?0:this.drawable.getBounds().width(); }
public int getIntrinsicHeight() { return this.drawable == null?0:this.drawable.getBounds().height() + 8; } }
public static Drawable insetBitmap(@NonNull Context context, @NonNull Bitmap bitmap) { BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), bitmap); bitmapDrawable.setBounds(0, 0, bitmapDrawable.getIntrinsicWidth(), bitmapDrawable.getIntrinsicHeight()); int inset = (DisplayUtils.getScreenWidth(context) - bitmapDrawable.getBounds().right) / 2; if (inset <= 0) { return bitmapDrawable; } InsetDrawable insetDrawable = new InsetDrawable(bitmapDrawable, inset, 0, inset, 0); insetDrawable.setBounds(0, 0, DisplayUtils.getScreenWidth(context), bitmapDrawable.getIntrinsicHeight()); return insetDrawable; } }
private void SetInnerBounds() { int X = getVirtBounds().centerX() + (int) ((axises[0]) * (getVirtBounds().width() / 2)); int Y = getVirtBounds().centerY() + (int) ((axises[1]) * (getVirtBounds().height() / 2)); if (X > getVirtBounds().centerX() + (getVirtBounds().width() / 2)) X = getVirtBounds().centerX() + (getVirtBounds().width() / 2); if (X < getVirtBounds().centerX() - (getVirtBounds().width() / 2)) X = getVirtBounds().centerX() - (getVirtBounds().width() / 2); if (Y > getVirtBounds().centerY() + (getVirtBounds().height() / 2)) Y = getVirtBounds().centerY() + (getVirtBounds().height() / 2); if (Y < getVirtBounds().centerY() - (getVirtBounds().height() / 2)) Y = getVirtBounds().centerY() - (getVirtBounds().height() / 2); int width = mPressedStateInnerBitmap.getBounds().width() / 2; int height = mPressedStateInnerBitmap.getBounds().height() / 2; mDefaultStateInnerBitmap.setBounds(X - width, Y - height, X + width, Y + height); mPressedStateInnerBitmap.setBounds(mDefaultStateInnerBitmap.getBounds()); }