MaskedEditText提示未在android中正确显示

时间:2017-09-15 08:47:59

标签: android

使用MaskedEditText是一个简单的Android EditText,具有可自定义的输入掩码支持。我有一个名为IP地址的字段。因为我必须将其设置为“000.000.000”格式。正确键入其设置。但提示是以不同的方式显示。使用这个gradle,

  

编译'ru.egslava:MaskedEditText:1.0.5'

我的xml代码就像,

        <br.com.sapereaude.maskedEditText.MaskedEditText
        android:id="@+id/rp_ipET"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="phone"
        android:typeface="monospace"
        mask:allowed_chars="1234567890"
        android:padding="6dp"
        android:hint="000.000.000"
        mask:mask="###.###.###"
        mask:keep_hint="true"
        />

在我的活动中,

    rp_ipET=(MaskedEditText)view.findViewById(R.id.rp_ipET);
    rp_ipET.setCharRepresentation('#');
    rp_ipET.setMask("###.###.###");

请查看随附的屏幕截图, MaskedEditTextHint

1 个答案:

答案 0 :(得分:2)

替换此

  mask:allowed_chars="1234567890"
    android:padding="6dp"
    android:hint="000.000.000"
    mask:mask="###.###.###"

通过

mask:allowed_chars="1234567890"
android:padding="6dp"
mask:mask="###.###.###"
android:hint="000000000"