TextInputLayout has no effect for giving hint programmatically in EditText

前端 未结 1 1300
孤街浪徒
孤街浪徒 2020-12-03 04:32

I have an EditText and it\'s parent is TextInputLayout. I am trying to give hint programmatically for EditText, (not in layout) in this case Text input hint animation is not

相关标签:
1条回答
  • 2020-12-03 04:57

    You have to set hint to TextInputLayout Here is the code.

    TextInputLayout textInputLayout = (TextInputLayout)findViewById(R.id.text_input_layout);
    textInputLayout.setHint("Hello");
    

    Updated

    In Kotlin:

    val textInputLayout = findViewById(R.id.text_input_layout)
    textInputLayout.hint = "Hello"
    
    0 讨论(0)
提交回复
热议问题