"advanced article" Android Learning Note--textinputlayout

Source: Internet
Author: User
<span id="Label3"></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">Google's new standard for unifying the vision and experience of the Android system is Android DESIGN. To make the old system compatible with the new standards, Google offers the Android Design support Library package, in which Android offers many new Controls. And Textinputlayout is from the Android Design support library Package.</p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">Textinputlayout is a new layout, from the inheritance tree, it inherits from linearlayout, but it does not support android:orientation properties, as Textinputlayout and scrollview, Only controls in which the only control can be Migrated. Also from Textinputlayout the name of this layout can be guessed, which is a layout specifically designed for text input actions. So textinputlayout is generally a control such as EditText or autocompletetextview, Textinputlayout provides a better display and experience for these Controls.</p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px; white-space:normal; "> Here is an example of a edittext that demonstrates the use and effects of Textinputlayout. The layout file is as Follows: </p></p><pre style="font-family:‘Courier New‘;font-size:12px;margin:5px 8px;padding:5px;"><android.support.design.widget.textinputlayout    android:layout_width= "match_parent"     android:layout_height= "wrap_content"     app:counterenabled= "true"     app:countermaxlength= "5"     app:hintanimationenabled= "true"      app:counteroverflowtextappearance= "@android: style/textappearance.devicedefault.large" >     <edittext        android:id= "@+id/password"         android:layout_width= "match_parent"          android:layout_height= "wrap_content"          Android:inputtype= "textpassword"         android:maxlines= "1"          android:hint= "@string/prompt_password"          android:Singleline= "true"  /></android.support.design.widget.TextInputLayout> </pre><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">The app is designed to use the new properties provided by the Android Design Support Library package, and a declaration that only needs to introduce the following namespaces on the root element of the layout file.</p></p><pre style="font-family:‘Courier New‘;font-size:12px;margin:5px 8px;padding:5px;"><pre style="font-family:‘Courier New‘;font-size:12px;margin:5px 8px;padding:5px;">xmlns:app= "http://schemas.android.com/apk/res-auto"</pre></pre><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">The layout file is set up and works as Shown:</p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">650) this.width=650; "src=" http://images2015.cnblogs.com/blog/324523/201603/324523-20160317154642803-405452068. GIF "style=" border:0px;margin-left:auto;margin-right:auto; "/></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">From the running results can be seen, the visual effect is significantly better than the mere use of edittext a lot better. Here Textinputlayout did a few things:</p></p> <ol style="padding-left:50px;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;" class="list-paddingleft-2"> <ol style="padding-left:50px;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;" class="list-paddingleft-2"> <li><p>Automatically calculates a padding to allow enough space for animation, error messages, and Word count.</p></li> <li><p>When EditText gets to the focus, it animates the hint in the EditText to the upper left, avoiding a bad experience when the edittext is used alone, prompting the message to not show when the focus is Taken.</p></li> <li><p>Count EditText words, and dynamically update the DISPLAY.</p></li> </ol> </ol><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">In textinputlayout, there are several important attributes:</p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p> <ul style="padding-left:40px;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;" class="list-paddingleft-2"> <ul style="padding-left:40px;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;" class="list-paddingleft-2"> <li><p>Counterenabled: whether to enable counters</p></li> <li><p>Countermaxlength: maximum word limit when the counter is enabled (only for Display)</p></li> <li><p>Counteroverflowtextappearance: font format when the number of words exceeds the maximum limit of the counter</p></li> <li><p>Hintanimationenabled: whether to enable hint animation effects</p></li> <li><p>Errorenabled: whether an error message is displayed</p></li> <li><p>Errortextappearance: font format for error messages</p></li> </ul> </ul><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">Welcome reprint, reproduced at the same time please respect the copyright, attached to the text link: <span style="color:rgb(255,0,0);"> <span style="color:rgb(255,0,0);">click here</span></span></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">==============================</p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">For more information, please see my blog: <span style="color:rgb(255,0,0);"> <span style="color:rgb(255,0,0);">Lin Yanjun's Blog</span></span></p></p><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;"><p style="margin:10px auto;font-family:verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;white-space:normal;">==============================</p></p><p><p><br></p></p><p><p>"advanced article" Android Learning Note--textinputlayout</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.