How to get text color of TextView?

前端 未结 4 1032
情歌与酒
情歌与酒 2021-01-31 13:23

In given code lbl[0].getTextColor() is giving Error but i don\'t know how to get text color of textview in java file please help me.

public void angry(View v)
{         


        
4条回答
  •  被撕碎了的回忆
    2021-01-31 14:19

    If you are using the contextcompat library to set the color for new versions of android, you may get a sightly different value then what was above. This test worked for me where I was using the following to set the test color

    view.setTextColor(ContextCompat.getColor(ctx, color));

        textColor =view.getCurrentTextColor();
        CoreApp.debug("viewutils", "green color: "+textColor);
        assertThat(textColor, is(ContextCompat.getColor(mCtx, R.color.green)));
    

提交回复
热议问题