Editbox Hint - Always show hint

后端 未结 2 1764
半阙折子戏
半阙折子戏 2021-01-21 01:56

I have a textbox with a hint but I want the hint to always be shown, even when there is an input in the TB. Example is the \"To\" field in the Gmail app.

2条回答
  •  感情败类
    2021-01-21 02:38

    There are 3 approaches you could use (spoiler - use number 3), since as mentioned in my comment, in the Gmail example , it is not an actual hint:

    1. Using a Linear Layout, getting a cleaner look in my opinion:

      
      
          
      
      
    2. Using a Relative Layout, getting a result that mimics the Gmail App:

      Note: might be problematic since the text will be displayed on top of the hint, see solution 3.

      
          
              
      

      Result are as shown in this image:

      Custom Permanent Hint

      Edit:

    3. using a Drawable:

      This seems a better solution (I personally just created it from snipping the 1:1 display of the TextView, will be in correct measurements this way), this will allow a cleaner layout code, and the text will be aware of the drawable:

      
          
      

      Drawable Hint

提交回复
热议问题