There is an ordinary TextView . How to set it a certain radius of borders not through XML?

Round textview

If, of course, there is a way that satisfies the condition below, I will be grateful.

I will explain why it is so important. The background color of this TextView is stored in a file, and more specifically, Properties . It is chosen arbitrarily by the user (for example, # 000000 is black, #FFFFFF is white, and so on ad infinitum). But how other people were asked to do here , here and here the desired color should already be known and specified in the solid tag.

    1 answer 1

    Judging by the issue of Google on request

    android rounded corners programmatically

    You will be satisfied with the answer on this link.

      PaintDrawable shape = new PaintDrawable(); //устанавливаем радиус скругления углов в пикселях shape.setCornerRadius( 8 ); //устанавливаем любой цвет, например красный shape.setColor(Color.RED); //устанавливаем полученный фон к-л вьюхе View view = ...; view.setBackground(shape); 
    • one
      Thank you for your reply. I will try to check soon. Now there is no time. - nick
    • For some reason, he writes an error that the setColor method does not exist. - nick
    • one
      @ L'Esperanza, then try GradientDrawable instead of PaintDrawable - Yuri Spb