How to make TextView shape circle and set different background color based on condition

后端 未结 5 1174
死守一世寂寞
死守一世寂寞 2020-12-08 08:09

I have a TextView, what I want is to make the TextView shape circle and then set different background colors based on different conditions I have u

5条回答
  •  眼角桃花
    2020-12-08 08:21

    TextView textView = (TextView) findViewById(R.id.my_text_view);             
    Drawable drawable = textView.getBackground();
    drawable.setColorFilter(getResources().getColor(color), PorterDuff.Mode.SRC_IN);
    

    works for me

提交回复
热议问题