Your draw should work fine. There must be something missing or something other than the draw that you are not doing right.
mpaint.setColor( Color.HSVToColor( new float[]{ 1f, 1f, 1f } ) );
The above should set color to red.
I have done similar to what you have done in onDraw() except that i changed the value and it works.
public class FingerPaintActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyView mv= new MyView(this);
setContentView(mv);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
class MyView extends View
{
Context c;
private Paint mpaint;
public MyView(Context context) {
super(context);
c= context;
mpaint= new Paint();
//mpaint.setColor(Color.RED);
mpaint.setColor( Color.HSVToColor( new float[]{ 0f, 0f, 0.5f } ) );
mpaint.setStyle(Paint.Style.FILL);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawRect(300, 100, 200, 300, mpaint);
}
}
}