Assuming that “the part inside the rectangle does not have the color of the content” means that you want to distinguish between the fillings inside the rectangle; you need to draw a rectangle inside your rectangle, then with a stroke width of 0 and the desired fill color.
For example:
DrawView.java
import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.View; public class DrawView extends View { Paint paint = new Paint(); public DrawView(Context context) { super(context); } @Override public void onDraw(Canvas canvas) { paint.setColor(Color.BLACK); paint.setStrokeWidth(3); canvas.drawRect(30, 30, 80, 80, paint); paint.setStrokeWidth(0); paint.setColor(Color.CYAN); canvas.drawRect(33, 60, 77, 77, paint ); paint.setColor(Color.YELLOW); canvas.drawRect(33, 33, 77, 60, paint ); } }
Actions to start:
StartDraw.java
import android.app.Activity; import android.graphics.Color; import android.os.Bundle; public class StartDraw extends Activity { DrawView drawView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); drawView = new DrawView(this); drawView.setBackgroundColor(Color.WHITE); setContentView(drawView); } }
... will be as follows:

DonGru Sep 08 2018-11-11T00: 00Z
source share