Back to project page akrellm.
The source code is released under:
Copyright (c) 2012, Tim Edwards All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project akrellm listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package yuku.ambilwarna.widget; //www . j a v a2 s . co m import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; import android.util.AttributeSet; import android.util.FloatMath; import android.view.View; public class AmbilWarnaPrefWidgetView extends View { Paint paint; float rectSize; float strokeWidth; public AmbilWarnaPrefWidgetView(Context context, AttributeSet attrs) { super(context, attrs); float density = context.getResources().getDisplayMetrics().density; rectSize = FloatMath.floor(24.f * density + 0.5f); strokeWidth = FloatMath.floor(1.f * density + 0.5f); paint = new Paint(); paint.setColor(0xffffffff); paint.setStyle(Style.STROKE); paint.setStrokeWidth(strokeWidth); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawRect(strokeWidth, strokeWidth, rectSize - strokeWidth, rectSize - strokeWidth, paint); } }