android - MaskedEditText 提示(android)

标签 android xml

我正在使用 maskedEditText图书馆。一切正常,但如果我设置 hint 它就不起作用了。示例:我有这个 xml:

 <br.com.sapereaude.maskedEditText.MaskedEditText 
                        android:id="@+id/phoneSend"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:hint="(111) 111 11 11"
                        android:inputType="number"
                        android:textColor="#fff"
                        android:layout_marginLeft="3dp"
                        android:background="@null"
                        mask:mask="(###) ###-##-##"
                    >
                    </br.com.sapereaude.maskedEditText.MaskedEditText>

如果我要输入文字:12345

它显示:23451

如果我删除 android:hint="(111) 111 11 11" 一切正常。但是我需要使用提示

最佳答案

包装您的 MaskedEditText 模板 TextInputLayout 并在其中键入提示:

    <android.support.design.widget.TextInputLayout
        android:id="@+id/tilPhoneNumber"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Input phone (111) 111-11-11">

        <br.com.sapereaude.maskedEditText.MaskedEditText
            android:id="@+id/metPhone"
            style="@style/..."
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:freezesText="true"
            android:inputType="number"
            android:typeface="monospace"
            app:allowed_chars="1234567890"
            app:keep_hint="true"
            app:mask="(###) ###-##-##"/>

    </android.support.design.widget.TextInputLayout>

关于android - MaskedEditText 提示(android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30547707/

相关文章:

android - Android通过API连接本地mysql数据库

XML 和 XSL 转换

c# - 使用 XML Serializer 序列化枚举——我保留了名称,但丢失了值。有什么办法可以同时保留两者?

php - 解析命名空间内的提要

java - 如何用 Gradle 生成 javadoc?

android - 在android中使用picasso到gridview中同时显示多张图片

android - 是否有任何 Android api 可以在 android 代码中以编程方式查找/感知室温?

java - 从 AsyncTask ProgressDialog 取消 AsyncTask

php - 如何将 CSS 格式应用于 EXCEL 表单输入字段

javascript - Google map 中的动态矩形