@Test public void testBoundsChanged() { Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888); CircularDrawable drawable = new CircularDrawable(bitmap); drawable.onBoundsChange(new Rect(0, 0, 500, 500)); }
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); centerX = bitmap.getWidth()/2f; centerY = bitmap.getHeight()/2f; float diameterMinX = Math.min(diameter, bitmap.getWidth()); float diameterMinY = Math.min(diameter, bitmap.getHeight()); matrix.reset(); matrix.setTranslate(-centerX + diameterMinX / 2, -centerY + diameterMinY / 2); shader.setLocalMatrix(matrix); }
CircularDrawable extends Drawable { @Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); centerX = bitmap.getWidth()/2f; centerY = bitmap.getHeight()/2f; float diameterMinX = Math.min(diameter, bitmap.getWidth()); float diameterMinY = Math.min(diameter, bitmap.getHeight()); matrix.reset(); matrix.setTranslate(-centerX + diameterMinX / 2, -centerY + diameterMinY / 2); shader.setLocalMatrix(matrix); } }
CircularDrawable extends Drawable { @Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); centerX = bitmap.getWidth()/2f; centerY = bitmap.getHeight()/2f; float diameterMinX = Math.min(diameter, bitmap.getWidth()); float diameterMinY = Math.min(diameter, bitmap.getHeight()); matrix.reset(); matrix.setTranslate(-centerX + diameterMinX / 2, -centerY + diameterMinY / 2); shader.setLocalMatrix(matrix); } CircularDrawable(Bitmap bitmap);  CircularDrawable(Bitmap bitmap, float explicitDiameter); }
CircularDrawable extends Drawable { @Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); centerX = bitmap.getWidth()/2f; centerY = bitmap.getHeight()/2f; float diameterMinX = Math.min(diameter, bitmap.getWidth()); float diameterMinY = Math.min(diameter, bitmap.getHeight()); matrix.reset(); matrix.setTranslate(-centerX + diameterMinX / 2, -centerY + diameterMinY / 2); shader.setLocalMatrix(matrix); } CircularDrawable(Bitmap bitmap);  CircularDrawable(Bitmap bitmap, float explicitDiameter); float getDiameter(); void setBorder(float borderWidth, int borderColor); void clearBorder(); @Override void draw(Canvas canvas); @Override int getOpacity(); @Override void setAlpha(int alpha); @Override void setColorFilter(ColorFilter cf); @Override int getIntrinsicHeight(); @Override int getIntrinsicWidth(); }
CircularDrawable extends Drawable { @Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); centerX = bitmap.getWidth()/2f; centerY = bitmap.getHeight()/2f; float diameterMinX = Math.min(diameter, bitmap.getWidth()); float diameterMinY = Math.min(diameter, bitmap.getHeight()); matrix.reset(); matrix.setTranslate(-centerX + diameterMinX / 2, -centerY + diameterMinY / 2); shader.setLocalMatrix(matrix); } CircularDrawable(Bitmap bitmap);  CircularDrawable(Bitmap bitmap, float explicitDiameter); float getDiameter(); void setBorder(float borderWidth, int borderColor); void clearBorder(); @Override void draw(Canvas canvas); @Override int getOpacity(); @Override void setAlpha(int alpha); @Override void setColorFilter(ColorFilter cf); @Override int getIntrinsicHeight(); @Override int getIntrinsicWidth();  }