N
N
Nikita2018-04-30 11:55:11
Android
Nikita, 2018-04-30 11:55:11

Why does the TextView have a screen size when creating a background?

I'm trying to draw a background for text, and the size of the background, as I found out, is the size of the layout in which it is created. And obviously I do not take the size of this layout anywhere.

public class FuryTextView extends TextView {
    private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    FuryTextView(Context context){
        super(context);
    }

    @Override
    public void draw(Canvas canvas) {
        canvas.drawColor(Color.RED);
          Rect rect = new Rect(3,3,3,3);
          RectF rectF = new RectF(rect);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            canvas.drawRoundRect(rectF, 30, 30, mPaint);
        } 
        super.draw(canvas);
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question