Android: Squared Diamond Drawable -
Android: Squared Diamond Drawable -
i'm trying create drawable utilize view background consists of single squared diamond centered. i've been playing trying create square , rotating 45 degrees, it's not working out i'd expect. wondering if has suggestions or working illustration offer help me out. i've tried making in xml, , switched trying in java, so:
public class diamondview extends drawable { private paint paint; public diamondview() { paint = new paint(); paint.setantialias(true); } @override public void draw(canvas canvas) { int height = getbounds().height(); int width = getbounds().width(); rectf rect = new rectf( 0.0f, 0.0f, height / 2, height / 2 ); canvas.rotate( 45 ); canvas.translate( width / 4, 0 ); canvas.drawrect( rect, paint ); } @override public void setalpha(int alpha) { paint.setalpha(alpha); } @override public void setcolorfilter(colorfilter cf) { paint.setcolorfilter(cf); } @override public int getopacity() { homecoming pixelformat.translucent; }
}
android android-drawable
Comments
Post a Comment