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;
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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;
    } 
 
} 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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);
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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);
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android NinePatchDrawable Questions & Answers:

See Code Examples for Android NinePatchDrawable Methods: