[Materialedittext] edittext of material design

Source: Internet
Author: User

With the advent of material design, appcompat V21 also provides visual support for material design controls, including edittext. However, edittext in appcompat is a bit difficult to use, because it uses col1_cent to automatically color the control and does not provide an API to set the color, therefore, you need to customize the color of the control by customizing theme for the control. Besides appearance changes, appcompat does not provide any features mentioned in Google material design spec. So I made this library: materialedittext. (In fact, a simple version has been ready for use some time ago, and the control will be re-built only after Google releases the new SDK and finds that the new SDK does not provide the expected support, made into the current version)

Features and usage:
  • Basic usage

Replace edittext with COM. rengwuxian. materialedittext. materialedittext in the layout file. Materialedittext is the directly inherited edittext without adding wrapper layout. Therefore, you do not need to modify the Java file in most cases.

<com.rengwuxian.materialedittext.MaterialEditText  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:hint="Basic"/>

  • Custom base color

Base color is used as the color of the background line, the color of the main font (transparency is reset to 87%), and the color of the prompt font (transparency is reset to 26% ). You can useapp:baseColor(XML) orsetBaseColor()(Java) to specify the base color. The default value of base color is pure black.

app:baseColor="#0056d3"

  • Custom primary color

Primary color is used as the background color, highlighted floating label color, and ellipsis at the bottom of the input box for activation. You can useapp:primaryColor(XML) orsetPrimaryColor()(Java) to specify the primary color. If primary color is not set, base color is used by default.

app:baseColor="#0056d3"app:primaryColor="#982360"

  • Floating label

Floating label has three modes:none,normal,highlight. You can useapp:floatingLabel(XML) orsetFloatingLabel()(Java) to set the floating label mode.

Normal:

app:floatingLabel="normal"

Highlight:

app:floatingLabel="highlight"

  • Ellipsis at the bottom

When the lower ellipsis is displayed, the control displays the ellipsis of three vertices on the left side of the text scroll to the left. Click the ellipsis to automatically place the cursor at the beginning of the string. You can useapp:singleLineEllipsis=true(XML) orsetSingleLineEllipsis()(Java) to set it. This property will be automatically setandroid:singleLineTrue.

Note: The ellipsis at the bottom automatically increases the height at the bottom of the control.

app:singleLineEllipsis="true"

  • Character Count limit

After setting the Character Count limit, the lower-right corner of the control displays the badge of the number of entered characters and the maximum number of characters, and the warning color (Red by default) is displayed after the limit is exceeded ). You can useapp:maxCharacters(XML) orsetMaxCharacters()(Java) to set the number of characters, throughapp:errorColorOrsetErrorColor()(Java) customize the warning color.

Note: The character number badge automatically increases the height at the bottom of the control.

Default error color:

app:maxCharacters="10"

Custom error color:

app:maxCharacters="10"  app:errorColor="#ddaa00"

GitHub address: materialedittext

Library download: MaterialEditText-1.0.0.aar

Sample download: MaterialEditText-1.0.0-sample.apk

This article is sent to my personal blog and open source China.

[Materialedittext] edittext of material design

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.