TEXT FIELD
From google material design documentation.
Text fields allow the user to input text, select text (cut, copy, paste), and lookup data via auto-completion.
HOW TO ADD?
I. In your build.gradle add latest appcompat library.
dependencies { compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version }
II. Make your activity extend android.support.v7.app.AppCompatActivity.
public class MainActivity extends AppCompatActivity { ... }
III. Declare your EditText inside any layout.xml file.
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Hint text"/>
I. Declare custom style in your styles.xml file.
<style name="MyEditText" parent="Theme.AppCompat.Light"> <item name="colorControlNormal">@color/indigo</item> <item name="colorControlActivated">@color/pink</item> </style>
II. Apply this style to your EditText via android:theme attribute.
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Hint text" android:theme="@style/MyEditText"/>
Comments
Post a Comment