0

I have a code.

    EditText editText = findViewById(R.id.editText);
    StateListDrawable gradientDrawable = (StateListDrawable) ContextCompat.getDrawable(this,R.drawable.cursor);
    DrawableContainer.DrawableContainerState drawableContainerState = (DrawableContainer.DrawableContainerState)gradientDrawable.getConstantState();
    Drawable[] children = drawableContainerState.getChildren();
    GradientDrawable selectedItem = (GradientDrawable)children[0];
    selectedItem.setColor(Color.BLUE);
    editText.setTextCursorDrawable(gradientDrawable);

But it does not change color dynamically.

0 Answers0