TextInputLayout not showing EditText hint before user focus on it

后端 未结 16 937
时光说笑
时光说笑 2020-11-27 13:50

I am using recently released Android Design Support Library to show floating label with EditTexts. But i am facing the problem that the Hint on the EditText is not showing w

16条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 14:12

    If you are setting your EditText hint programmatically it wouldn't work! You need to set the hint on the TextInputLayout it self.

    TextInputLayout textInputLayout = (TextInputLayout) findViewById(R.id.usernameTextInputLayout);
    textInputLayout.setHint(getString(R.string.username_hint));
    

    Here is the XML in case you are wondering:

            
    
                
    
            
    

提交回复
热议问题