TextInputLayout输入一个文本后如何隐藏错误EditText.可能吗?
我怎么能做到这一点,或者我在这里做错了什么.!!
码
layoutEdtPhone =(TextInputLayout)rootView.findViewById(R.id.layoutEdtPhone);
layoutEdtPhone.setErrorEnabled(true);
layoutEdtPhone.setError(getString(R.string.ui_no_phone_toast));
layoutEdtPassword = (TextInputLayout)rootView.findViewById(R.id.layoutEdtPassword);
layoutEdtPassword.setErrorEnabled(true);
layoutEdtPassword.setError(getString(R.string.ui_no_password_toast));
edtPhone=(EditText)rootView.findViewById(R.id.edtPhone);
edtPassword=(EditText)rootView.findViewById(R.id.edtPassword);
Run Code Online (Sandbox Code Playgroud)
XML
<EditText
android:id="@+id/edtPhone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="@drawable/edt_background_selector"
android:drawableLeft="@drawable/phone_icon"
android:drawableStart="@drawable/phone_icon"
android:hint="@string/phone"
android:inputType="phone"
android:padding="5dip"
android:singleLine="true"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/layoutEdtPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/edtPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/edt_background_selector"
android:drawableLeft="@drawable/password_icon"
android:drawableStart="@drawable/password_icon"
android:hint="@string/password"
android:inputType="textPassword"
android:padding="5dip"
android:singleLine="true"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能始终保持标签扩展,无论是否有文本EditText.我在源头环顾四周,它是一个使用a ValueAnimator和一个counter内部TextWatcher来动画或不动画更改.也许我可以在里面设置一个自定义TextWatcher的自定义?ValueAnimatorEditTextTextInputLayout
我想在这些方面做点什么:
我能够显示提示android:hint="Email Address"但无法显示帮助文本 - 这将是您的电子邮件用户名
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="15"
android:hint="Username"
app:et_helper="Username is preferably your registered email"/>
</android.support.design.widget.TextInputLayout>`
Run Code Online (Sandbox Code Playgroud)
我得到的只是,并且没有用户名最好是您在edittext下面注册的电子邮件:
输出:
任何指针赞赏.谢谢.
android android-layout android-edittext androiddesignsupport android-textinputlayout
我正在使用TextInputLayoutandroid 设计库版本 25.1.1。使用以下代码:
<android.support.design.widget.TextInputLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
local:passwordToggleEnabled="true"
local:hintEnabled="false">
<android.support.design.widget.TextInputEditText
android:id="@+id/confirmationEditText"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
但是当按下密码切换图标时,它的涟漪效果会被绘制在 TextInput 的背景之上:

如何设置圆角半径passwordToggle?我可以引用它现有的背景并用所需的属性“包装”它吗(如何找到切换使用的默认可绘制对象的路径)?
android android-layout xamarin android-design-library android-textinputlayout
我使用TextInputLayout与设计支持库22.2.1.
我以EditText编程方式设置了值,当屏幕出现时,我可以看到TextInputLayout在移动到浮动位置之前,文本内部重叠的提示.
这是一个简单的布局:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint1" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
在我的Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
EditText e1 = (EditText) findViewById(R.id.editText1);
e1.setText("TEXT TEST 1");
}
Run Code Online (Sandbox Code Playgroud)
有没有人知道解决方法?

android android-support-library material-design android-support-design android-textinputlayout
我已经尝试了很多,但是AutoCompleteTextView使用TextInputLayoutfrom支持无法使工作成为浮动提示.
有可能或者我需要使用外部库吗?
android autocompletetextview android-support-library material-design android-textinputlayout
是否可以在 Jetpack Compose 的 TextField 中获得不同的颜色?
类似于Text可组合 with AnnotatedString,但 TextField 不允许AnnotatedString作为输入值。
可与颜色组合的普通文本图像
android kotlin android-textinputlayout android-jetpack-compose android-compose-textfield
我正在尝试使用Material Design中的TextInputEditText(https://github.com/material-components/material-components-android/blob/master/docs/components/TextInputLayout.md),我得到了运行时异常.
这是运行日志的一部分:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.grigori.materialtextedit, PID: 12036
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.grigori.materialtextedit/com.example.grigori.materialtextedit.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.google.android.material.textfield.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: android.view.InflateException: Binary …Run Code Online (Sandbox Code Playgroud) android android-edittext android-textinputlayout android-textinputedittext
今天我刚刚更新了我dependencies的material design
从1.0.0到1.1.0-alpha09
implementation 'com.google.android.material:material:1.1.0-alpha09'
Run Code Online (Sandbox Code Playgroud)
现在我遇到了奇怪的问题 com.google.android.material.textfield.TextInputLayout
这是我的代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_enter_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
更新依赖项后,我在我的 TextInputLayout
上面代码的输出
如果我使用implementation 'com.google.android.material:material:1.0.0'我会得到预期的结果
谁能帮我解决这个问题
如果需要更多信息,请告诉我。提前致谢。您的努力将不胜感激。
更新
我已经试过
app:boxBackgroundMode="none"了,我得到了这个
,
如果我使用
app:boxBackgroundMode="outline"然后得到这个

无需使用 boxBackgroundMode
你需要@style/Widget.Design.TextInputLayout在你的TextInputLayout
示例代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp"
style="@style/Widget.Design.TextInputLayout"
app:errorTextAppearance="@style/error_appearance"
android:textColorHint="@android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:id="@+id/emailTextInputEditText"
android:layout_height="wrap_content"
android:backgroundTint="@android:color/white"
android:gravity="center"
android:hint="@string/hint_enter_email"
android:imeOptions="actionNext"
android:textColorHint="@android:color/white"
android:inputType="textEmailAddress"
android:textColor="@android:color/white"
android:textSize="@dimen/_15ssp"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
android android-layout material-design android-textinputlayout androidx
我注意到几天以来,我所有的 TextInputLayouts 总是启用“错误感叹号”。我已经很长时间没有对那些 TextInputLayouts 进行任何更改,所以我真的不明白发生了什么。
这是它的外观截图:

你知道这个问题的根源是什么吗?TextInputLayouts 最近有什么变化吗?
非常感谢您提前
这是相关代码: .xml 文件非常简单。它是一个 TextInputLayouts 和 EditTexts 列表,如下所示:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginRight="@dimen/default_margin">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/txtAddressTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/PROFILE_SCREEN_ADDRESS_INPUT_TITLE"
android:inputType="textPersonName|textCapWords" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
此外,我的 Kotlin 代码中绝对没有提到 setError()。