25

xml では、ドローアブルを TextView のテキストの左、右、下、または上に設定できます。コードを使用してこのドローアブルを設定/変更する方法はありますか?

4

1 に答える 1

66
TextView textView = (TextView)findViewById(R.id.myTxtView);
textView.setCompoundDrawablesWithIntrinsicBounds(
  R.drawable.icon, //left
  0, //top
  0, //right
  0);//bottom
于 2012-10-02T04:49:59.167 に答える