Android PaintDrawable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PaintDrawable class.

This code example shows how to use the following methods:setIntrinsicHeight, setIntrinsicWidth
This code example shows how to use the following methods:setShaderFactory, setShape
      Toast.makeText(context, result, Toast.LENGTH_SHORT).show();
      return System.currentTimeMillis();
   } 
    
   public static PaintDrawable getPaintDrawable(int startX, int endX){
      PaintDrawable drawable = new PaintDrawable();
      drawable.setShape(new RectShape());
      drawable.setShaderFactory(getShaderFactory(startX, endX));
      return drawable;
   } 
 
   public static ShapeDrawable.ShaderFactory
   getShaderFactory(final int startX, final int endX){
      return new ShapeDrawable.ShaderFactory(){
 
         @Override 
         public Shader resize(int width, int height) {
            return new LinearGradient(startX, 0, endX, 0,
                  new int[]{ 0xFFDCDAD5, 0xFFFDFDF4, 
                  0xFFFFFFFF, 0xFFFDFBEF }, 
7
CodeRank
This code example shows how to use the following methods:
	} 
 
	public void setBackgroundColor(int backgroundColor) {
		//this.background = new ColorDrawable(backgroundColor); 
		releaseDelegate(); 
		this.background = new PaintDrawable(backgroundColor);
	} 
 
	public void setBackgroundImage(Bitmap backgroundImage) {
		releaseDelegate(); 
		this.background = new BitmapDrawable(backgroundImage);
	} 
 
	public void setBackgroundDrawable(Drawable drawable) {
		releaseDelegate(); 
		this.background = drawable;
		onStateChange(getState());
	} 
 
	@Override 
7
CodeRank
This code example shows how to use the following methods:setIntrinsicHeight, setIntrinsicWidth
This code example shows how to use the following methods:setIntrinsicHeight, setIntrinsicWidth
This code example shows how to use the following methods:getPaint, setShape
			} 
			else 
			{ 
				color = getColor("gray", 0.2f);
			} 
			border = new PaintDrawable();
			border.setShape(new RoundRectShape(roundedCorner, null, roundedCorner));
			border.getPaint().setColor(color);
			border.getPaint().setStyle(Style.STROKE);
			border.getPaint().setStrokeWidth(borderWidth);
			 
			// add the highlight layer 
			PaintDrawable highlight = new PaintDrawable();
			highlight.setShape(new RoundRectShape(roundedCorner, null, roundedCorner));
			highlight.getPaint().setColor(Color.parseColor("#404040"));		// 0.25 red, 0.25 blue, 0.25 green
 
			// layer the bottom and shine 
			int layer = 0;
			Drawable[] drawNormal = new Drawable[numLayers];
			drawNormal[layer++] = (Drawable)normal;
6
CodeRank
This code example shows how to use the following methods:setCornerRadius, setIntrinsicHeight, setIntrinsicWidth
        if ( data.getPhotoUri() != null ) {
            mPhoto.setImageURI(Uri.parse(data.getPhotoUri()));
        } else { 
            mPhoto.setImageResource(android.R.drawable.ic_dialog_info);
        } 
        PaintDrawable p = new PaintDrawable(Color.BLACK);
        p.setIntrinsicHeight(40);
        p.setIntrinsicWidth(40);
        p.setCornerRadius(6);
//        mPhoto.setBackgroundDrawable(p); 
    } 
 
    public Contact getData() { 
        return mData;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setCornerRadius, setIntrinsicHeight, setIntrinsicWidth
	public int getColor() { 
		return mColor;
	} 
 
	public static Drawable getDrawable(int color) {
		PaintDrawable drawable = new PaintDrawable(color);
		drawable.setIntrinsicHeight(32);
		drawable.setIntrinsicWidth(32);
		drawable.setCornerRadius(4);
		return drawable;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:setCornerRadius
5
CodeRank
This code example shows how to use the following methods:setIntrinsicHeight, setIntrinsicWidth

Related Android PaintDrawable Questions & Answers:

See Code Examples for Android PaintDrawable Methods: