Hint Not Displaying When numeric=“integer” in Edit

2019-05-10 12:29发布

问题:

The title is the question.

Anybody know any solution?

Please help me.


Shaiful

回答1:

The XML attribute android:numeric is not a boolean value and "true" is not a valid parameter, it must be one ore more of "integer", "signed", "decimal".

Per the sample you've posted, your issue is due to the choice of adding gravity to center the text. There is a known bug in the SDK that, as of 2.3, it looks like is still not fixed. This bug hides the hint text when android:singleLine and any custom value of android:gravity are set together. Your choice at this juncture really is to remove one or the other. Some workaround options:

  1. Remove the android:gravity declaration and have the text left-aligned.
  2. Keep the declaration and remove android:singleLine. In this case, you will probably have to override the Editor Action in order to get the default Next or Done button on the soft keypad.
  3. Remove android:gravity, and set layout_width="wrap_content". Then appropriately center the entire widget in the parent layout. This may look a little goofy with the standard EditText background as it will grow and shrink. You may have to set this to null and make the background part of a parent container.

Also, don't forget to star the bug :)

Cheers.



回答2:

I think you should use one of the attributes specified here for the numeric attribute. Not sure if it solves the problem but you should use one of those values as it states: "Must be one or more (separated by '|') of the following constant values."



回答3:

I was struggling with this issue myself and none of the posts I found here could help me out.

Then when I was fiddeling with the EditText again, I found out that the hint does show when an android:inputType was assigned in combination with android:ellipsize.

A later search pointed into the same direction: http://code.google.com/p/android/issues/detail?id=7252

Still it's a weird issue, which should already be fixed...