{"id":831,"date":"2022-12-13T18:00:00","date_gmt":"2024-01-08T21:00:49","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/"},"modified":"2025-08-03T11:42:49","modified_gmt":"2025-08-03T03:42:49","slug":"android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/","title":{"rendered":"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7"},"content":{"rendered":"<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u4e86\u89e3Android TextInputLayout\u63d0\u4f9b\u7684\u529f\u80fd\u3002Android TextInputLayout\u662f\u4e00\u4e2a\u5e26\u6709Material Design\u652f\u6301\u5e93\u7684\u8bbe\u8ba1\u7ec4\u4ef6\u3002<\/p>\n<h2>\u5b89\u5353\u7684\u6587\u672c\u8f93\u5165\u5e03\u5c40<\/h2>\n<p>Android\u7684TextInputLayout\u7ee7\u627f\u81eaLinearLayout\u3002TextInputLayout\u7684\u4e3b\u8981\u7528\u9014\u662f\u4f5c\u4e3aEditText\uff08\u6216\u5176\u5b50\u7c7b\uff09\u7684\u5305\u88c5\u5668\uff0c\u5e76\u542f\u7528\u6d6e\u52a8\u63d0\u793a\u52a8\u753b\u3002\u7ecf\u9a8c\u6cd5\u5219\uff1aTextInputLayout\u5e94\u8be5\u5305\u88c5TextInputEditText\u800c\u4e0d\u662f\u666e\u901a\u7684EditText\u3002\u539f\u56e0\u662f\uff1fTextInputEditText\u662fEditText\u7684\u5b50\u7c7b\uff0c\u4e13\u95e8\u8bbe\u8ba1\u7528\u4f5cTextInputLayout\u7684\u5b50\u63a7\u4ef6\u3002\u6b64\u5916\uff0c\u4f7f\u7528EditText\u4f1a\u53d1\u51fa\u8b66\u544a\uff1a\u6dfb\u52a0\u7684EditText\u4e0d\u662fTextInputEditText\uff0c\u8bf7\u6539\u7528\u8be5\u7c7b\u3002TextInputLayout\u4e0d\u4ec5\u53ef\u4ee5\u663e\u793a\u6d6e\u52a8\u63d0\u793a\u6807\u7b7e\uff0c\u8fd8\u63d0\u4f9b\u4e86\u66f4\u591a\u529f\u80fd\u3002<\/p>\n<h3>\u5b89\u5353\u7684TextInputLayout\u529f\u80fd<\/h3>\n<p>\u5728\u8fd9\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f1a\u4ecb\u7ecd\u4e00\u4e9b\u529f\u80fd\uff1a<\/p>\n<ul>\n<li>\u542f\u7528\/\u7981\u7528\u6d6e\u52a8\u63d0\u793a<\/li>\n<li>\u542f\u7528\/\u7981\u7528\u6d6e\u52a8\u63d0\u793a\u52a8\u753b<\/li>\n<li>\u663e\u793a\u9519\u8bef\u6d88\u606f<\/li>\n<li>\u663e\u793a\u5b57\u7b26\u8ba1\u6570\u5668<\/li>\n<li>\u5f53\u5b57\u7b26\u8ba1\u6570\u8d85\u8fc7\u9650\u5236\u65f6\u63d0\u9192\u7528\u6237<\/li>\n<li>\u81ea\u5b9a\u4e49\u6d6e\u52a8\u63d0\u793a\u3001\u9519\u8bef\u6807\u7b7e\u3001\u5b57\u7b26\u8ba1\u6570\u5668\u7684\u6587\u672c\u5916\u89c2<\/li>\n<li>\u5bc6\u7801\u53ef\u89c1\u6027\u5207\u6362<\/li>\n<\/ul>\n<p>\u6211\u4eec\u5c06\u4f1a\u9010\u4e00\u7814\u7a76\u8fd9\u4e9b\u7279\u70b9\uff0c\u5e76\u5728Android Studio\u9879\u76ee\u4e2d\u5b9e\u73b0\u5b83\u4eec\u3002<\/p>\n<h3>Android TextInputLayout\u793a\u4f8b\u9879\u76ee\u7ed3\u6784<\/h3>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5355Activity\u5e94\u7528\u7a0b\u5e8f\u3002\u6211\u4eec\u5c06\u5728layout\u3001activity\u548cstyles.xml\u4ee5\u53cacolors.xml\u6587\u4ef6\u4e2d\u5b8c\u6210\u6240\u6709\u7684\u5de5\u4f5c\u3002\u9996\u5148\uff0c\u6309\u7167\u4e0b\u9762\u6240\u793a\uff0c\u5728build.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5173\u4e8edesign support library\u7684\u4f9d\u8d56\u3002<\/p>\n<pre class=\"post-pre\"><code>compile 'com.android.support:design:25.3.1'<\/code><\/pre>\n<h3>\u542f\u7528\/\u7981\u7528\u60ac\u6d6e\u63d0\u793a<\/h3>\n<p>\u5728TextInputLayout\u4e2d\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u542f\u7528\u4e86\u6d6e\u52a8\u63d0\u793a\u3002\u8981\u7981\u7528\u5b83\uff0c\u6211\u4eec\u9700\u8981\u5728\u6807\u7b7e\u5185\u6dfb\u52a0\u4ee5\u4e0b\u5c5e\u6027\uff1aapp:hintEnabled=&#8221;false&#8221;\u3002\u4e0b\u9762\u7684xml\u4ee3\u7801\u6765\u81eaactivity_main.xml\u5e03\u5c40\uff0c\u5305\u542b\u4e09\u4e2aEditText\u5b57\u6bb5\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;ScrollView xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"https:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    tools:context=\"com.Olivia.featuresoftextinputlayout.MainActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"vertical\"&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputEditText\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            android:hint=\"TextInputEditText\" \/&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"Floating Hint Enabled Default\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:hintEnabled=\"false\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"Floating Hint Disabled\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/ScrollView&gt;<\/code><\/pre>\n<p>\u7b2c\u4e09\u4e2aEditText\u5b57\u6bb5\u7684\u6d6e\u52a8\u63d0\u793a\u88ab\u7981\u7528\u3002\u8ba9\u6211\u4eec\u770b\u770b\u4e0a\u8ff0\u4ee3\u7801\u7684\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<h3>\u542f\u7528\/\u7981\u7528\u6d6e\u52a8\u63d0\u793a\u52a8\u753b<\/h3>\n<p>\u8fd9\u662f\u6587\u7ae0\u300aAndroid\u7684TextInputLayout\u793a\u4f8b\u300b\u7684\u7b2c2\u90e8\u5206\uff08\u51715\u90e8\u5206\uff09\u3002<\/p>\n<p>\u4e0e\u4e4b\u524d\u7684\u7279\u6027\u7c7b\u4f3c\uff0cTextInputLayout\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u542f\u7528\u4e86\u6d6e\u52a8\u63d0\u793a\u52a8\u753b\u3002\u8981\u7981\u7528\u6b64\u52a8\u753b\uff0c\u6211\u4eec\u9700\u8981\u5728TextInputLayout\u6807\u7b7e\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5c5e\u6027\uff1aapp:hintAnimationEnabled=&#8221;false&#8221;\u3002\u4e0b\u9762\u7684XML\u4ee3\u7801\u6765\u81eaactivity_main.xml\u5e03\u5c40\u6587\u4ef6\uff0c\u5176\u4e2d\u5c55\u793a\u4e86\u4e24\u79cd\u60c5\u51b5\u4e0b\u7684EditText\u5b57\u6bb5\u5b9e\u73b0\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;ScrollView xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"https:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    tools:context=\"com.Olivia.featuresoftextinputlayout.MainActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"vertical\"&gt;\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u9ed8\u8ba4\u542f\u7528\u6d6e\u52a8\u63d0\u793a\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:hintAnimationEnabled=\"false\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u7981\u7528\u63d0\u793a\u52a8\u753b\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/ScrollView&gt;\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u7684\u8f93\u51fa\u6548\u679c\u5982\u4e0b\u6240\u793a\u3002\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u5f53\u7b2c\u4e8c\u4e2aEditText\u5b57\u6bb5\u83b7\u5f97\u7126\u70b9\u65f6\uff0c\u5176\u6d6e\u52a8\u63d0\u793a\u5c06\u4e0d\u4f1a\u663e\u793a\u52a8\u753b\u6548\u679c\u3002<\/p>\n<h3>\u8bbe\u7f6e\u63d0\u793a\u6587\u672c\u7684\u5916\u89c2<\/h3>\n<p>\u8981\u4e3a\u63d0\u793a\u6587\u672c\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u989c\u8272\u548c\u5927\u5c0f\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u5c5e\u6027\uff1aapp:hintTextAppearance=&#8221;@style\/HintText&#8221;\u3002\u5728styles.xml\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u9762\u7684\u793a\u4f8b\u5b9a\u4e49HintText\u6837\u5f0f\uff1a<\/p>\n<pre class=\"post-pre\"><code>&lt;style name=\"HintText\" parent=\"TextAppearance.Design.Hint\"&gt;\r\n        &lt;item name=\"android:textSize\"&gt;16sp&lt;\/item&gt;\r\n        &lt;item name=\"android:textColor\"&gt;@color\/colorPrimary&lt;\/item&gt;\r\n    &lt;\/style&gt;\r\n<\/code><\/pre>\n<p>\u4e0b\u9762\u7684XML\u4ee3\u7801\u6765\u81eaactivity_main.xml\u5e03\u5c40\u6587\u4ef6\uff0c\u5c55\u793a\u4e86\u4e24\u79cd\u60c5\u51b5\uff08\u4f7f\u7528\u548c\u672a\u4f7f\u7528hintTextAppearance\u5c5e\u6027\uff09\u7684EditText\u5b57\u6bb5\u5b9e\u73b0\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;ScrollView xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"https:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    tools:context=\"com.Olivia.featuresoftextinputlayout.MainActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"vertical\"&gt;\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u542f\u7528\u6d6e\u52a8\u63d0\u793a\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:hintTextAppearance=\"@style\/HintText\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u81ea\u5b9a\u4e49\u63d0\u793a\u6587\u672c\u5916\u89c2\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/ScrollView&gt;\r\n<\/code><\/pre>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u7684\u8f93\u51fa\u6548\u679c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<h3>\u5b57\u7b26\u8ba1\u6570\u5668<\/h3>\n<p>\u5b57\u7b26\u8ba1\u6570\u5668\u662f\u8bb8\u591a\u5e94\u7528\u7a0b\u5e8f\u5e38\u7528\u7684\u529f\u80fd\uff08\u4f8b\u5982Twitter\u7684\u5b57\u7b26\u9650\u5236\uff09\u3002\u901a\u8fc7\u5c06app:counterEnabled\u8bbe\u7f6e\u4e3atrue\uff0c\u5e76\u4f7f\u7528app:counterMaxLength\u5c5e\u6027\uff0c\u53ef\u4ee5\u8bbe\u7f6eTextInputLayout\u4e2d\u7684\u6700\u5927\u5b57\u7b26\u6570\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u8ba1\u6570\u5668\u663e\u793a\u5728EditText\u7684\u53f3\u4e0b\u89d2\u4f4d\u7f6e\uff0c\u5728\u7f16\u5199\u672c\u6559\u7a0b\u65f6\uff0c\u5c1a\u65e0\u6539\u53d8\u5176\u4f4d\u7f6e\u7684\u65b9\u6cd5\u3002\u8bbe\u7f6e\u8ba1\u6570\u5668\u6837\u5f0f\u7684\u65b9\u5f0f\u4e0e\u8bbe\u7f6e\u63d0\u793a\u6587\u672c\u6837\u5f0f\u7c7b\u4f3c\uff0c\u8fd9\u91cc\u4f7f\u7528\u7684\u5c5e\u6027\u662fapp:counterTextAppearance\u3002\u6211\u4eec\u5728\u9879\u76ee\u7684styles.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e86\u4ee5\u4e0b\u6837\u5f0f\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;style name=\"CounterText\" parent=\"TextAppearance.Design.Counter\"&gt;\r\n        &lt;item name=\"android:textSize\"&gt;16sp&lt;\/item&gt;\r\n        &lt;item name=\"android:textColor\"&gt;@color\/my_pink&lt;\/item&gt;\r\n    &lt;\/style&gt;\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0bXML\u4ee3\u7801\u6765\u81eaactivity_main.xml\u5e03\u5c40\u6587\u4ef6\uff0c\u5c55\u793a\u4e86\u5305\u542b\u9ed8\u8ba4\u5b57\u7b26\u8ba1\u6570\u5668\u548c\u81ea\u5b9a\u4e49\u5b57\u7b26\u8ba1\u6570\u5668\u7684EditText\u5b57\u6bb5\u5b9e\u73b0\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;ScrollView xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"https:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    tools:context=\"com.Olivia.featuresoftextinputlayout.MainActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"vertical\"&gt;\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:hintTextAppearance=\"@style\/HintText\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u5b57\u7b26\u8ba1\u6570\u5668\u9650\u5236\u4e3a10\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:counterTextAppearance=\"@style\/CounterText\"\r\n            app:hintTextAppearance=\"@style\/HintText\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u81ea\u5b9a\u4e49\u6587\u672c\u5916\u89c2\u7684\u5b57\u7b26\u8ba1\u6570\u5668\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/ScrollView&gt;\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u7684\u8f93\u51fa\u6548\u679c\u5982\u4e0b\u3002\u8ba9\u6211\u4eec\u4ed4\u7ec6\u89c2\u5bdf\u8fd9\u4e9b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<ul class=\"post-ul\">\n<li>\u7b2c\u4e00\u4e2aEditText\u5b57\u6bb5\u5728\u5b57\u7b26\u8ba1\u6570\u8d85\u8fc7\u9650\u5236\u65f6\uff0c\u4f1a\u6539\u53d8\u8ba1\u6570\u5668\u7684\u6587\u672c\u989c\u8272\u3001\u63d0\u793a\u6587\u672c\u989c\u8272\u548c\u6307\u793a\u5668\u989c\u8272\u3002<\/li>\n<li>\u7b2c\u4e8c\u4e2aEditText\u5b57\u6bb5\u5728\u8d85\u8fc7\u9650\u5236\u65f6\u4e5f\u4f1a\u6267\u884c\u76f8\u540c\u64cd\u4f5c\uff0c\u6b64\u5916\u8fd8\u4f1a\u6539\u53d8\u8ba1\u6570\u5668\u7684\u81ea\u5b9a\u4e49\u6587\u672c\u989c\u8272\u548c\u81ea\u5b9a\u4e49\u6587\u672c\u5927\u5c0f\u3002<\/li>\n<\/ul>\n<p>\u5f53\u5b57\u7b26\u8ba1\u6570\u8d85\u8fc7\u9650\u5236\u65f6\uff0c\u82e5\u8981\u6307\u5b9a\u6211\u4eec\u60f3\u8981\u7684\u6837\u5f0f\uff0c\u9700\u8981\u4f7f\u7528\u63a5\u4e0b\u6765\u5c06\u8981\u4ecb\u7ecd\u7684counterOverflow\u5c5e\u6027\u3002<\/p>\n<h3>\u5b57\u7b26\u8ba1\u6570\u5668\u6ea2\u51fa<\/h3>\n<p>\u6b63\u5982\u6211\u4eec\u5728\u4e0a\u9762\u6240\u770b\u5230\u7684\uff0c\u5f53\u5b57\u7b26\u6570\u8d85\u8fc7\u5b9a\u4e49\u7684\u9650\u5236\u65f6\uff0c\u8ba1\u6570\u5668\u6587\u672c\u4f1a\u4f7f\u7528\u5728counterOverflow\u4e2d\u5b9a\u4e49\u7684\u5c5e\u6027\u3002\u5982\u679c\u8be5\u5c5e\u6027\u4e0d\u5b58\u5728\uff0c\u5b83\u5c06\u4f7f\u7528\u9ed8\u8ba4\u5c5e\u6027\uff0c\u6b63\u5982\u6211\u4eec\u5728\u4e0a\u9762\u7684\u8f93\u51fa\u4e2d\u6240\u770b\u5230\u7684\u90a3\u6837\u3002\u6211\u4eec\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u53c2\u6570\uff1aapp:counterOverflowTextAppearance\u3002CounterOverflow\u7684\u6837\u5f0f\u5728styles.xml\u6587\u4ef6\u4e2d\u5b9a\u4e49\u3002<\/p>\n<pre class=\"post-pre\"><code> &lt;style name=\"CounterOverFlow\" parent=\"TextAppearance.Design.Counter.Overflow\"&gt;\r\n        &lt;item name=\"android:textSize\"&gt;16sp&lt;\/item&gt;\r\n        &lt;item name=\"android:textColor\"&gt;@color\/my_orange&lt;\/item&gt;\r\n    &lt;\/style&gt;\r\n<\/code><\/pre>\n<p>\u5c06\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u6dfb\u52a0\u5230\u4e4b\u524d\u7684activity_main.xml\u5e03\u5c40\u6587\u4ef6\u4e2d\uff1a<\/p>\n<pre class=\"post-pre\"><code>&lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:counterOverflowTextAppearance=\"@style\/CounterOverFlow\"\r\n            app:counterTextAppearance=\"@style\/CounterText\"\r\n            app:hintTextAppearance=\"@style\/HintText\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u81ea\u5b9a\u4e49\u6587\u672c\u5916\u89c2\u7684\u8ba1\u6570\u5668\u6ea2\u51fa\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n<\/code><\/pre>\n<p>\u8ba9\u6211\u4eec\u518d\u6b21\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u67e5\u770b\u6548\u679c\u3002<\/p>\n<h3>\u9519\u8bef\u6807\u7b7e<\/h3>\n<p>\u5c06app:errorEnabled\u8bbe\u7f6e\u4e3atrue\u53ef\u4ee5\u4f7f\u6211\u4eec\u5728EditText\u5b57\u6bb5\u4e0b\u65b9\u663e\u793a\u4e00\u4e2a\u9519\u8bef\u6587\u672c\u3002\u8981\u6837\u5f0f\u5316\u9519\u8bef\u6587\u672c\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5c5e\u6027app:errorTextAppearance\uff0c\u5e76\u5728styles.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;style name=\"ErrorText\" parent=\"TextAppearance.Design.Error\"&gt;\r\n        &lt;item name=\"android:textSize\"&gt;16sp&lt;\/item&gt;\r\n        &lt;item name=\"android:textColor\"&gt;@color\/my_black&lt;\/item&gt;\r\n    &lt;\/style&gt;\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u7684XML\u4ee3\u7801\u6765\u81eaactivity_main.xml\u5e03\u5c40\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u9519\u8bef\u6807\u7b7e\u548c\u4e00\u4e2a\u81ea\u5b9a\u4e49\u9519\u8bef\u6807\u7b7e\u7684EditText\u5b57\u6bb5\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;ScrollView xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"https:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    tools:context=\"com.Olivia.featuresoftextinputlayout.MainActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"vertical\"&gt;\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:id=\"@+id\/errorInputLayout\"\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:counterOverflowTextAppearance=\"@style\/CounterOverFlow\"\r\n            app:counterTextAppearance=\"@style\/CounterText\"\r\n            app:errorEnabled=\"true\"\r\n            app:hintTextAppearance=\"@style\/HintText\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:id=\"@+id\/errorEditText\"\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"Default Error Label\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:id=\"@+id\/customErrorInputLayout\"\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:counterOverflowTextAppearance=\"@style\/CounterOverFlow\"\r\n            app:counterTextAppearance=\"@style\/CounterText\"\r\n            app:errorEnabled=\"true\"\r\n            app:errorTextAppearance=\"@style\/ErrorText\"\r\n            app:hintTextAppearance=\"@style\/HintText\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:id=\"@+id\/customErrorEditText\"\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"Custom Error Label\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/ScrollView&gt;\r\n<\/code><\/pre>\n<p>\u8981\u663e\u793a\u9519\u8bef\u6587\u672c\uff0c\u6211\u4eec\u9700\u8981\u5728MainActivity.java\u7c7b\u4e2d\u8c03\u7528TextInputLayout\u5b9e\u4f8b\u7684setError(String)\u65b9\u6cd5\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.Olivia.featuresoftextinputlayout;\r\n\r\nimport android.support.design.widget.TextInputEditText;\r\nimport android.support.design.widget.TextInputLayout;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.text.Editable;\r\nimport android.text.TextWatcher;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\n\r\n    TextInputLayout errorInputLayout, customErrorInputLayout;\r\n    TextInputEditText errorEditText, customErrorEditText;\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n\r\n        errorEditText = (TextInputEditText) findViewById(R.id.errorEditText);\r\n        errorInputLayout = (TextInputLayout) findViewById(R.id.errorInputLayout);\r\n\r\n        customErrorEditText = (TextInputEditText) findViewById(R.id.customErrorEditText);\r\n        customErrorInputLayout = (TextInputLayout) findViewById(R.id.customErrorInputLayout);\r\n\r\n        errorEditText.addTextChangedListener(new TextWatcher() {\r\n            @Override\r\n            public void beforeTextChanged(CharSequence s, int start, int count, int after) {\r\n\r\n            }\r\n\r\n            @Override\r\n            public void onTextChanged(CharSequence s, int start, int before, int count) {\r\n\r\n            }\r\n\r\n            @Override\r\n            public void afterTextChanged(Editable s) {\r\n\r\n                if (s.length() &gt; errorInputLayout.getCounterMaxLength())\r\n                    errorInputLayout.setError(\"Max character length is \" + errorInputLayout.getCounterMaxLength());\r\n                else\r\n                    errorInputLayout.setError(null);\r\n\r\n            }\r\n        });\r\n\r\n        customErrorEditText.addTextChangedListener(new TextWatcher() {\r\n            @Override\r\n            public void beforeTextChanged(CharSequence s, int start, int count, int after) {\r\n\r\n            }\r\n\r\n            @Override\r\n            public void onTextChanged(CharSequence s, int start, int before, int count) {\r\n\r\n            }\r\n\r\n            @Override\r\n            public void afterTextChanged(Editable s) {\r\n\r\n                if (s.length() &gt; customErrorInputLayout.getCounterMaxLength())\r\n                    customErrorInputLayout.setError(\"Max character length is \" + customErrorInputLayout.getCounterMaxLength());\r\n                else\r\n                    customErrorInputLayout.setError(null);\r\n\r\n            }\r\n        });\r\n\r\n\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u5728\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5728\u6bcf\u4e2aTextInputEditText\u5b9e\u4f8b\u4e0a\u6dfb\u52a0\u4e86\u4e00\u4e2a\u5b9e\u73b0\u4e86TextWatcher\u63a5\u53e3\u7684TextChangedListener\u3002\u5f53\u8f93\u5165\u7684\u5b57\u7b26\u8ba1\u6570\u8d85\u8fc7\u8ba1\u6570\u5668\u7684\u6700\u5927\u9650\u5236\u65f6\uff0c\u6211\u4eec\u4f1a\u663e\u793a\u9519\u8bef\u6807\u7b7e\u3002\u4e3a\u4e86\u6e05\u9664\u9519\u8bef\u6807\u7b7e\uff0c\u6211\u4eec\u5c06setError()\u65b9\u6cd5\u4e2d\u7684\u503c\u8bbe\u7f6e\u4e3anull\u3002\u4ee5\u4e0a\u4ee3\u7801\u7684\u8f93\u51fa\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u6587\u672c\u5b57\u6bb5\u7684\u6307\u793a\u5668\u4f7f\u7528\u4e0e\u9519\u8bef\u6807\u7b7e\u76f8\u540c\u7684\u989c\u8272\u3002\u5b83\u4f1a\u8986\u76d6\u7531counterOverflow\u8bbe\u7f6e\u7684\u989c\u8272\uff0c\u56e0\u6b64\u62e5\u6709\u6700\u9ad8\u7684\u4f18\u5148\u7ea7\u3002<\/p>\n<h3>\u5bc6\u7801\u53ef\u89c1\u6027\u5207\u6362<\/h3>\n<p>\u5c06app:passwordToggleEnabled\u5c5e\u6027\u8bbe\u7f6e\u4e3atrue\u53ef\u4ee5\u542f\u7528\u5bc6\u7801\u663e\u793a\/\u9690\u85cf\u529f\u80fd\u3002\u82e5\u8981\u66f4\u6539\u5207\u6362\u56fe\u6807\u989c\u8272\uff0c\u53ef\u4ee5\u4f7f\u7528app:passwordToggleTint\u5c5e\u6027\u3002\u4e0b\u9762\u7684XML\u4ee3\u7801\u6765\u81eaactivity_main.xml\u5e03\u5c40\u6587\u4ef6\uff0c\u5176\u4e2d\u5c55\u793a\u4e86\u7528\u4e8e\u5bc6\u7801\u53ef\u89c1\u6027\u5207\u6362\u7684EditText\u5b57\u6bb5\uff08\u5305\u62ec\u9ed8\u8ba4\u56fe\u6807\u548c\u81ea\u5b9a\u4e49\u8272\u8c03\u7684\u793a\u4f8b\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;ScrollView xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"https:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    tools:context=\"com.Olivia.featuresoftextinputlayout.MainActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"vertical\"&gt;\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:counterOverflowTextAppearance=\"@style\/CounterOverFlow\"\r\n            app:counterTextAppearance=\"@style\/CounterText\"\r\n            app:hintTextAppearance=\"@style\/HintText\"\r\n            app:passwordToggleEnabled=\"true\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u5bc6\u7801\u53ef\u89c1\u6027\u5207\u6362\"\r\n                android:inputType=\"textPassword\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n\r\n\r\n        &lt;android.support.design.widget.TextInputLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"@dimen\/activity_horizontal_margin\"\r\n            app:counterEnabled=\"true\"\r\n            app:counterMaxLength=\"5\"\r\n            app:counterOverflowTextAppearance=\"@style\/CounterOverFlow\"\r\n            app:counterTextAppearance=\"@style\/CounterText\"\r\n            app:hintTextAppearance=\"@style\/HintText\"\r\n            app:passwordToggleEnabled=\"true\"\r\n            app:passwordToggleTint=\"@color\/my_orange\"&gt;\r\n\r\n            &lt;android.support.design.widget.TextInputEditText\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:hint=\"\u5bc6\u7801\u53ef\u89c1\u6027\u5207\u6362\uff08\u81ea\u5b9a\u4e49\u8272\u8c03\uff09\"\r\n                android:inputType=\"textPassword\" \/&gt;\r\n\r\n        &lt;\/android.support.design.widget.TextInputLayout&gt;\r\n&lt;\/LinearLayout&gt;\r\n&lt;\/ScrollView&gt;\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u7684\u8f93\u51fa\u6548\u679c\u5982\u4e0b\uff1a\u8bf7\u6ce8\u610f\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528app:passwordToggleDrawable\u5c5e\u6027\u6765\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u56fe\u6807\uff0c\u4ee5\u66ff\u4ee3\u9ed8\u8ba4\u7684\u5bc6\u7801\u53ef\u89c1\u6027\u5207\u6362\u56fe\u6807\u3002\u81f3\u6b64\uff0c\u672c\u6559\u7a0b\u5df2\u5168\u90e8\u7ed3\u675f\u3002\u6211\u4eec\u5df2\u7ecf\u4ecb\u7ecd\u4e86TextInputLayout\u4e2d\u7684\u6240\u6709\u4e3b\u8981\u529f\u80fd\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e0b\u65b9\u94fe\u63a5\u4e0b\u8f7d\u5b8c\u6574\u7684Android TextInputLayout\u793a\u4f8b\u9879\u76ee\uff0c\u8be5\u9879\u76ee\u5305\u542b\u4e86\u4ee5\u4e0a\u6240\u6709\u4ee3\u7801\u7247\u6bb5\u3002<\/p>\n<p>\u4e0b\u8f7d Android TextInputLayout \u9879\u76ee<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a\u5b89\u5353\u5b98\u65b9\u6587\u6863<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u4e86\u89e3Android TextInputLayout\u63d0\u4f9b\u7684\u529f\u80fd\u3002Android TextI [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1270,900,904,1029,2188],"class_list":{"0":"post-831","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"tag-android-ui","8":"tag-android","10":"tag-material-design","11":"tag-textinputlayout"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android TextInputLayout\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u5f00\u53d1\u6280\u5de7\u3002\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0Material Design\u98ce\u683c\u7684\u8f93\u5165\u6846\uff0c\u5305\u62ec\u9519\u8bef\u63d0\u793a\u3001\u5b57\u7b26\u8ba1\u6570\u3001\u5bc6\u7801\u5207\u6362\u7b49\u529f\u80fd\uff0c\u63d0\u5347Android\u5e94\u7528\u7684\u7528\u6237\u4f53\u9a8c\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/android\u7684textinputlayout\u793a\u4f8b\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android TextInputLayout\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u5f00\u53d1\u6280\u5de7\u3002\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0Material Design\u98ce\u683c\u7684\u8f93\u5165\u6846\uff0c\u5305\u62ec\u9519\u8bef\u63d0\u793a\u3001\u5b57\u7b26\u8ba1\u6570\u3001\u5bc6\u7801\u5207\u6362\u7b49\u529f\u80fd\uff0c\u63d0\u5347Android\u5e94\u7528\u7684\u7528\u6237\u4f53\u9a8c\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/android\u7684textinputlayout\u793a\u4f8b\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-08T21:00:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-03T03:42:49+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u96c5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u96c5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/\",\"name\":\"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-01-08T21:00:49+00:00\",\"dateModified\":\"2025-08-03T03:42:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\"},\"description\":\"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android TextInputLayout\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u5f00\u53d1\u6280\u5de7\u3002\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0Material Design\u98ce\u683c\u7684\u8f93\u5165\u6846\uff0c\u5305\u62ec\u9519\u8bef\u63d0\u793a\u3001\u5b57\u7b26\u8ba1\u6570\u3001\u5bc6\u7801\u5207\u6362\u7b49\u529f\u80fd\uff0c\u63d0\u5347Android\u5e94\u7528\u7684\u7528\u6237\u4f53\u9a8c\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\",\"name\":\"\u79d1, \u96c5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u96c5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7 - Blog - Silicon Cloud","description":"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android TextInputLayout\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u5f00\u53d1\u6280\u5de7\u3002\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0Material Design\u98ce\u683c\u7684\u8f93\u5165\u6846\uff0c\u5305\u62ec\u9519\u8bef\u63d0\u793a\u3001\u5b57\u7b26\u8ba1\u6570\u3001\u5bc6\u7801\u5207\u6362\u7b49\u529f\u80fd\uff0c\u63d0\u5347Android\u5e94\u7528\u7684\u7528\u6237\u4f53\u9a8c\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/android\u7684textinputlayout\u793a\u4f8b\/","og_locale":"zh_CN","og_type":"article","og_title":"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7","og_description":"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android TextInputLayout\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u5f00\u53d1\u6280\u5de7\u3002\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0Material Design\u98ce\u683c\u7684\u8f93\u5165\u6846\uff0c\u5305\u62ec\u9519\u8bef\u63d0\u793a\u3001\u5b57\u7b26\u8ba1\u6570\u3001\u5bc6\u7801\u5207\u6362\u7b49\u529f\u80fd\uff0c\u63d0\u5347Android\u5e94\u7528\u7684\u7528\u6237\u4f53\u9a8c\u3002","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/android\u7684textinputlayout\u793a\u4f8b\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-01-08T21:00:49+00:00","article_modified_time":"2025-08-03T03:42:49+00:00","author":"\u79d1, \u96c5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u96c5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/","name":"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-01-08T21:00:49+00:00","dateModified":"2025-08-03T03:42:49+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a"},"description":"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android TextInputLayout\u7ec4\u4ef6\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u5f00\u53d1\u6280\u5de7\u3002\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0Material Design\u98ce\u683c\u7684\u8f93\u5165\u6846\uff0c\u5305\u62ec\u9519\u8bef\u63d0\u793a\u3001\u5b57\u7b26\u8ba1\u6570\u3001\u5bc6\u7801\u5207\u6362\u7b49\u529f\u80fd\uff0c\u63d0\u5347Android\u5e94\u7528\u7684\u7528\u6237\u4f53\u9a8c\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u8be6\u89e3Android TextInputLayout\uff1a\u5b9e\u7528\u793a\u4f8b\u4e0e\u5f00\u53d1\u6280\u5de7"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a","name":"\u79d1, \u96c5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","caption":"\u79d1, \u96c5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e7%9a%84textinputlayout%e7%a4%ba%e4%be%8b\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=831"}],"version-history":[{"count":4,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/831\/revisions"}],"predecessor-version":[{"id":110760,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/831\/revisions\/110760"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}