progressDrawable.setDrawableByLayerId(progressDrawable.getId(2), new ClipDrawable(...));
protected void refreshDrawable(final Drawable drawable) { mDrawable = drawable; if (mDrawable == null) { mDrawable = new ColorDrawable(mColor); } int gravity = GRAVITY_FILL_VERTICAL | GRAVITY_LEFT; int orientation = ClipDrawable.HORIZONTAL; switch (mRotation) { case 90: gravity = GRAVITY_FILL_HORIZONTAL | GRAVITY_BOTTOM; orientation = ClipDrawable.VERTICAL; break; case 180: gravity = GRAVITY_FILL_VERTICAL | GRAVITY_RIGHT; orientation = ClipDrawable.HORIZONTAL; break; case 270: gravity = GRAVITY_FILL_HORIZONTAL | GRAVITY_TOP; orientation = ClipDrawable.VERTICAL; break; } mClipDrawable = new ClipDrawable(mDrawable, gravity, orientation); final Rect outRect = new Rect(); getDrawingRect(outRect); mClipDrawable.setBounds(outRect); mClipDrawable.setLevel((int)(mProgress * mScale) + mMin); postInvalidate(); } }
@Override public void run() { if (mClipDrawable != null) { int level = (int)(mProgress * mScale) + mMin; if (level < 0) level = 0; if (level > 10000) level = 10000; mClipDrawable.setLevel(level); } invalidate(); } };
@Override protected void onDraw(final Canvas canvas) { super.onDraw(canvas); mClipDrawable.draw(canvas); }
@Override public void run() { mHandle.sendEmptyMessage(0X0000); if (mWaterDrawable.getLevel() >= 10000) { timer.cancel(); } } }, 0, 50);
public void resetAnim() { mWaterDrawable.setLevel(0); mWaterView.resetBubbleAnim(); mFlameView.stopFlaming(); mPea1.setVisibility(INVISIBLE); mPea2.setVisibility(INVISIBLE); mPotato.setVisibility(INVISIBLE); mCarrot.setVisibility(INVISIBLE); mCoverView.setVisibility(INVISIBLE); } }
private Drawable createClipDrawable(@ColorInt int colour) { ShapeDrawable shapeDrawable = createShapeDrawable(colour); return new ClipDrawable(shapeDrawable, Gravity.START, ClipDrawable.HORIZONTAL); }
/** * ATTENTION: This was auto-generated to implement the App Indexing API. * See https://g.co/AppIndexing/AndroidStudio for more information. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.a_animaltest); ButterKnife.bind(this); flowLayoutZone1 = (FlowLayout) findViewById(R.id.flowLayoutZone1); iv_iv = (ImageView) findViewById(R.id.iv_iv); sv = (ScrollView) findViewById(R.id.sv); testViewTreeObserverListener(); bt = BitmapFactory.decodeResource(getResources(), R.drawable.abcd); ClipDrawable drawable = (ClipDrawable) btClipDrawable.getBackground(); drawable.setLevel(5000);//0-10000 }
private Drawable[] createDrawables(Bitmap[] bitmaps) { Drawable[] pieces = new Drawable[bitmaps.length]; for (int i = 0; i < bitmaps.length; i++) { BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), bitmaps[i]); bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); if (i == 0) { pieces[i] = bitmapDrawable; } else { pieces[i] = new ClipDrawable(bitmapDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); } } return pieces; }
private Drawable createClipDrawable(@ColorInt int colour) { ShapeDrawable shapeDrawable = createShapeDrawable(colour); return new ClipDrawable(shapeDrawable, Gravity.START, ClipDrawable.HORIZONTAL); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView imageview = (ImageView) findViewById(R.id.image); imageview.setBackgroundResource(R.drawable.icon); ClipDrawable drawable = (ClipDrawable) imageview.getDrawable(); if(drawable != null){ drawable.setLevel(drawable.getLevel() + 1000); //Line number 21 } }
public void run(RapidParserObject object, Object view, Var value) { ((ProgressBar)view).setProgressDrawable(new ClipDrawable(new ColorDrawable(Color.parseColor("#" + value.getString())), Gravity.LEFT, ClipDrawable.HORIZONTAL)); } }
private void initMaskBitmap(int maskColor) { Drawable drawable = getDrawable(); if(drawable == null){ return; } Bitmap bgd = ((BitmapDrawable) drawable).getBitmap(); imageWidth = drawable.getIntrinsicWidth(); imageHeight = drawable.getIntrinsicHeight(); Bitmap fg = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888); Canvas fgCanvas = new Canvas(fg); fgCanvas.drawColor(maskColor); Bitmap bitmap = combineImages(bgd, fg); maskDrawable = new BitmapDrawable(bitmap); clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion); //shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); //paint.setShader(shader); }
/** * 设置方向 * @param orientation {@link MaskOrientation} */ public void setMaskOrientation(int orientation){ switch (orientation){ case MaskOrientation.LeftToRight: gravity = Gravity.LEFT; orientaion = ClipDrawable.HORIZONTAL; break; case MaskOrientation.RightToLeft: gravity = Gravity.RIGHT; orientaion = ClipDrawable.HORIZONTAL; break; case MaskOrientation.TopToBottom: gravity = Gravity.TOP; orientaion = ClipDrawable.VERTICAL; break; case MaskOrientation.BottomToTop: default: gravity = Gravity.BOTTOM; orientaion = ClipDrawable.VERTICAL; break; } if(maskDrawable == null){ return; } clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion); initAnim(); }
public void setFilledDrawable(Drawable drawable) { if (drawable.getConstantState() == null) { return; } ClipDrawable clipDrawable = new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.START, ClipDrawable.HORIZONTAL); mFilledView.setImageDrawable(clipDrawable); }
public void setFilledDrawable(Drawable drawable) { if (drawable.getConstantState() == null) { return; } ClipDrawable clipDrawable = new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.START, ClipDrawable.HORIZONTAL); mFilledView.setImageDrawable(clipDrawable); }