Created
April 13, 2015 10:14
-
-
Save happycodinggirl/68d12f9fc592ae4f5482 to your computer and use it in GitHub Desktop.
ShapeDrawable的使用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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