Getting started with android-edittext

Download android-edittext eBook

Remarks

This section provides an overview of what android-edittext is, and why a developer might want to use it.

It should also mention any large subjects within android-edittext, and link out to the related topics. Since the Documentation for android-edittext is new, you may need to create initial versions of those related topics.

Specifying Text Hints

It is possible to specify a text hint when using EditTexts. Text hints are useful for conveying to the user what they should type in the EditText.

In XML:

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="username" />
 

The content of the hint (in our example, 'username') can be anything you like.

Styling In EditText

Changing the edit text's appearance when it's selected, pressed and not selected can be customised easily by adding creating a new style for your edit text like so

<style name="EditTextTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">@color/colorPrimary</item>
    <item name="colorControlActivated">@color/colorPrimaryDark</item>
    <item name="colorControlHighlight">@color/accent</item>
</style>
 

And then add this style to your EditText like

<EditText
    android:width="wrap_content"
    android:height="wrap_content"
    style="@style/EditTextTheme" />
 

Stats

16 Contributors: 3
Friday, May 26, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook