Today this article should be considered as a supplement to the material Design series, because this article should have been put to the front, because it is about the subject, for some status and color introduction, because when we create a new project, the system comes with three attributes of the color, The significance and effect of these three color attributes are now highlighted. Understand this and keep it for another use.
Three most commonly used color properties
- Colorprimary
- Colorprimarydark
- Coloraccent
What do these three separate means?
- Colorprimarydark is the status bar background
- Colorprimary If you do not manually modify the toolbar background color, it is the default toolbar background color
- Coloraccent each control element (e.g. checkbox, switch or radio) is checked (checked) or selected (selected) color
The text description may not be very intuitive, take a look at the picture, as follows:
Other properties related to introduction
- Navigationbarcolor the background color of the navigation bar, but can only be used in the API level 21 or above, that is, more than 5.0 to
- The background color of the Windowbackground App
- Colorcontrolnormal This can only be used in API21 or above to use the preset color of each control element and the coloraccent exactly correspond
Set on Style
The color properties above are set in the properties of the style. As follows:
The description of the properties of these colors is here, I believe everyone should understand. If the light of the article is a little short, not very full, so today we add two very simple Material design style of the control, probably everyone knows, know not to see HA, skip just fine.
Textinputlayout
Textinputlayout inherits the LinearLayout, so we need to include editview within the textinputlayout to use, the implication: Textinputlayout cannot be used alone. The inside can contain one and only one edittext, unlike the traditional edittext, when the input EDITTEXT the hint hint text will slide to the top, the user input at the same time prompts the user to enter what is currently, but also can set the input error prompt information.
The code layout is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<Android.support.design.widget.TextInputLayout Android:id="@+id/email_textlayout" Android:layout_width="Match_parent" android:layout_height="Wrap_content" android:layout_marginleft="20DP" android:layout_marginright="20DP" android:layout_margintop="35DP" >
<edittext Android:id= "@+id/email_et" android:layout_width= "match_parent" android:layout_height= "wrap_content" android:hint= "Please enter your mailbox" android:inputtype= "textemailaddress" android:textcolor= "@color/text_color"/> </android.support.design.widget.textinputlayout> /span> |
The common methods of Textinputlayout are as follows:
- Sethint (): Sets the prompt.
- Getedittext (): Gets the EditView control in the Textinputlayout.
- Seterrorenabled (): Sets whether an error message can be displayed.
- SetError (): Sets the error message that pops up when the user enters an error.
Special Note: Textinputlayout cannot be used alone, must be wrapped editview components, and only one, set the error message must first seterrorenabled (true), and then set the SetError ().
Textinputedittext
Like Textinputedittext and Textinputlayout, the design package also has a component Textinputedittext, which inherits the Appcompatedittext, which displays a small pop-up prompt with error messages on the right. Usage and textinputedittext are similar, and without setting error message elimination, re-textinputedittext output will be automatically canceled, very flexible and user-friendly.
The usage is simple:
1 2 3 4 5 6 7 8 9
|
<Android.support.design.widget.TextInputEditText android:id="@+id/pwd_et" android:layout_width="Match_parent" android:layout_height="Wrap_content" android:layout_marginleft="20DP" android:layout_marginright="20DP" android:hint="Please enter your password" android:inputtype="Textemailaddress" android:textcolor="@color/text_color"/>
|
To here today's content is finished, Material design series actually not finished, today said the theme style, next time it is possible to say according to the theme style set night mode, as well as the future transitions animation and so on. This series may have some basis, but tune also please understand, will students can skip, will not be good study. In short, it is for everyone to further. The heavy mouth is difficult to adjust, also please everybody understanding.
Demo GitHub address: Https://github.com/loonggg/MaterialDesignDemo to star Bar, I will gradually improve.
Introduction to the theme of the Android Material design series