在xml中,您可以在TextView中将文本的左侧,右侧,底部或顶部设置为drawable。有没有办法通过代码设置/更改此drawable?
答案 0 :(得分:63)
TextView textView = (TextView)findViewById(R.id.myTxtView);
textView.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.icon, //left
0, //top
0, //right
0);//bottom