12

I have an EditText like below:

<EditText
android:id="@+id/et_sum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@android:drawable/editbox_background"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:hint="Enter sum" />

But the hint is not displayed. Is it possible to display the EditText hint with inputType="numberDecimal" or not?

Anne
  • 26,765
  • 9
  • 65
  • 71
IgorOK
  • 1,652
  • 4
  • 18
  • 36
  • It seems unnecessary to me to use `android:background="@android:drawable/editbox_background"`. Is there any change if you remove that? – skynet Nov 16 '11 at 18:52

4 Answers4

21

you can use

android:ellipsize="start"

to make the hint displayed with an inputtype and gravity

SKT
  • 1,821
  • 1
  • 20
  • 32
6

It appears to be a problem with using android:gravity="center_horizontal". Try removing that line as it made the hint appear for me.

skynet
  • 9,898
  • 5
  • 43
  • 52
  • Well, it was the issue, but when you want to center the text and focus the cursor in the center, then you got a problem. here is the solution if that is the case. android:ellipsize="start" android:singleLine="true" – Nizzy Apr 25 '14 at 03:10
2

Here is one of my EditText tags to compare with:

<EditText
         android:id="@+id/txtNumbText"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:textSize="18sp"
         android:inputType="numberDecimal"
         android:singleLine="true"
         android:hint="Number Hint Text">
</EditText>
Bryan
  • 3,629
  • 2
  • 28
  • 27
1

Hi we can not use Gravity attribute and inputtype="number" attribute at a time so better to neglect gravity attribute.

if u want set hint in middle of edit text use like this : android:hint=" hint "

give space in hint text

<EditText android:id="@+id/xEt" android:layout_width="170dip"
            android:layout_height="wrap_content"
            android:layout_marginRight="20dip"
            android:inputType="number"
            android:hint="   numbers only "
            android:layout_alignParentRight="true" />
sravan
  • 5,303
  • 1
  • 31
  • 33