EditText hint doesn't show

前端 未结 10 1733
生来不讨喜
生来不讨喜 2020-12-05 04:23

My EditText configured as follows won\'t show the hint:



        
相关标签:
10条回答
  • 2020-12-05 04:36

    I changed the style to "@style/Base.WidgetMaterialComponents.TextImputEditText". For me it wasn't gravity or color.

    0 讨论(0)
  • 2020-12-05 04:37

    Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :(

    I found no other solution than to:

    if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*"))
          editText.setGravity(Gravity.LEFT);
    else
          editText.setGravity(Gravity.CENTER);
    
    0 讨论(0)
  • 2020-12-05 04:38

    The below worked for me:

    <EditText
        android:id="@+id/UserText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignRight="@+id/UserPassword"
        android:layout_marginTop="85dp"
        android:ems="10"
        android:hint="@string/UserHint"
        android:inputType="textPersonName"
        android:singleLine="true"
        android:text="@string/UserName" >
    
        <requestFocus />
    </EditText>
    
    0 讨论(0)
  • 2020-12-05 04:38

    Try changing the hint text color, sometimes the hint color is the same as the background color

    android:textColorHint="@color/colorBlack"
    
    0 讨论(0)
  • 2020-12-05 04:43

    In Lollipop version the default text and hint text color is white for EditText. So we have to change like this in EditText

    android:textColorHint="@color/grey"
    
    0 讨论(0)
  • 2020-12-05 04:47

    I wanted my single-line EditText box to scroll but keep the hint on the right also. I had the same issue and got the hint to stick by keeping gravity="right", and setting singleLine="true" and ellipsize="end".

    0 讨论(0)
提交回复
热议问题