Android NinePatchDrawable - 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 NinePatchDrawable class.

This code example shows how to use the following methods:setBounds, draw, getPaint
This code example shows how to use the following methods:
 
        if (chunk != null && bitmap != null) {
            int[] padding = chunk.getPadding();
            Rect paddingRect = new Rect(padding[0], padding[1], padding[2], padding[3]);
 
            return new NinePatchDrawable(context.getResources(), bitmap,
                    NinePatch_Delegate.serialize(chunk),
                    paddingRect, null);
        } 
 
        return null; 
    } 
 
    // ------- TypedValue stuff 
    // This is taken from //device/libs/utils/ResourceTypes.cpp 
 
    private static final class UnitEntry { 
        String name;
        int type;
        int unit;
6
CodeRank
This code example shows how to use the following methods:setBounds, draw
	 
	public static Bitmap getNinePatch(int id, int x, int y, Context context){
        // id is a resource id for a valid ninepatch 
		 
        byte[] chunk = BitmapFactory.decodeResource(context.getResources(), id).getNinePatchChunk();
        NinePatchDrawable np_drawable = new NinePatchDrawable(context.getResources(), BitmapFactory.decodeResource(context.getResources(), id), chunk, new Rect(), null);
	    np_drawable.setBounds(0, 0, x, y);
		 
	    Bitmap output_bitmap = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_8888);
	    Canvas canvas = new Canvas(output_bitmap);
	    np_drawable.draw(canvas);
	     
	    np_drawable = null;
	    return output_bitmap;
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:setBounds, draw
  @Override 
  protected void onDraw(Canvas canvas) {
    if (buttonRect != null) {
      Rect myRect = new Rect();
      if (getGlobalVisibleRect(myRect)) {
        highlightDrawable.setBounds(drawRect);
        highlightDrawable.draw(canvas);
      } 
    } 
  } 
 
  public void drawButtonHighlight(Rect rect) {
    if (highlightDrawable != null) {
      if (buttonRect != null) {
        invalidate(drawRect);
      } 
      buttonRect = rect;
      drawRect = getHighlightRectangle(buttonRect);
      invalidate(drawRect);
    } 
5
CodeRank
This code example shows how to use the following methods:setBounds, draw
  @Override 
  protected void onDraw(Canvas canvas) {
    if (buttonRect != null) {
      Rect myRect = new Rect();
      if (getGlobalVisibleRect(myRect)) {
        highlightDrawable.setBounds(drawRect);
        highlightDrawable.draw(canvas);
      } 
    } 
  } 
 
  public void drawButtonHighlight(Rect rect) {
    if (highlightDrawable != null) {
      if (buttonRect != null) {
        invalidate(drawRect);
      } 
      buttonRect = rect;
      drawRect = getHighlightRectangle(buttonRect);
      invalidate(drawRect);
    } 
5
CodeRank
This code example shows how to use the following methods:setBounds, draw
This code example shows how to use the following methods:setBounds, draw
  @Override 
  protected void onDraw(Canvas canvas) {
    if (buttonRect != null) {
      Rect myRect = new Rect();
      if (getGlobalVisibleRect(myRect)) {
        highlightDrawable.setBounds(drawRect);
        highlightDrawable.draw(canvas);
      } 
    } 
  } 
 
  public void drawButtonHighlight(Rect rect) {
    if (highlightDrawable != null) {
      if (buttonRect != null) {
        invalidate(drawRect);
      } 
      buttonRect = rect;
      drawRect = getHighlightRectangle(buttonRect);
      invalidate(drawRect);
    } 
5
CodeRank
This code example shows how to use the following methods:setBounds, draw
  @Override 
  protected void onDraw(Canvas canvas) {
    if (buttonRect != null) {
      Rect myRect = new Rect();
      if (getGlobalVisibleRect(myRect)) {
        highlightDrawable.setBounds(drawRect);
        highlightDrawable.draw(canvas);
      } 
    } 
  } 
 
  public void drawButtonHighlight(Rect rect) {
    if (highlightDrawable != null) {
      if (buttonRect != null) {
        invalidate(drawRect);
      } 
      buttonRect = rect;
      drawRect = getHighlightRectangle(buttonRect);
      invalidate(drawRect);
    } 
5
CodeRank
This code example shows how to use the following methods:setBounds, draw
This code example shows how to use the following methods:setBounds, draw
		c.rotate(rotation, cardDim.left+offsetx, cardDim.top+offsety);
		//drawDebugPoint(cardDim.left, cardDim.top, c); 
		cardDim.inset(-2, -3);
		if (selected)
		{ 
			selshadow.setBounds(cardDim);
			selshadow.draw(c);
		} 
		else 
		{ 
			shadow.setBounds(cardDim);
			shadow.draw(c);
		} 
		cardDim.inset(2, 3);
		c.drawRect(cardDim, fillStyle);
		updateTextStyle(); 
		c.drawText(cardText, cardDim.centerX(), cardDim.centerY(), textStyle);
		//drawDebugPoint(cardDim.left + (int) offsetx, cardDim.top + (int) offsety, c); 
	} 
	 
4
CodeRank

Related Android NinePatchDrawable Questions & Answers:

See Code Examples for Android NinePatchDrawable Methods: