Skip to content

Instantly share code, notes, and snippets.

@happycodinggirl
Created April 13, 2015 10:14
Show Gist options
  • Save happycodinggirl/68d12f9fc592ae4f5482 to your computer and use it in GitHub Desktop.
Save happycodinggirl/68d12f9fc592ae4f5482 to your computer and use it in GitHub Desktop.
ShapeDrawable的使用
package com.lily.huangxingli.svgexample;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.view.View;
/**
* Created by huangxingli on 2015/4/13.
*/
public class CustomDrawableView extends View {
private ShapeDrawable mDrawable;
public CustomDrawableView(Context context) {
super(context);
int x = 10;
int y = 10;
int width = 300;
int height = 50;
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.getPaint().setColor(0xff74AC23);
mDrawable.setBounds(x, y, x + width, y + height);
}
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment