如何编程设置drawableRight在Android EDITTEXT?drawableRight、Android、EDITTEXT

2023-09-06 03:22:10 作者:獨來獨往

我是知道的设置drawableRight XML格式。但我需要做programetically,因为它是改变按一定的条件。

I know about set drawableRight in XML. but i required to do it programetically because it is change as per some condition.

推荐答案

您可以使用下面的功能:

You can use the function below:

editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.drawableRight, 0);

相应的绘制位置PARAMS的顺序是:左,上,右,下

The order of params corresponding to the drawable location is: left, top, right, bottom