Reputation: 543
I want to group together the label (e.g. "StaffID") and the value of the textView (e.g. "S1234567") together, vertically, in Android. The label stays on top the textView value throughout while the user is typing in the value in the textView. Attached is the screenshot of how I want the UI to look like.
Click here to view the UI screenshot
Upvotes: 1
Views: 741
Reputation: 1293
<android.support.design.widget.TextInputLayout
android:id="@+id/inputlayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:theme="@style/loginActivityHintStyle">
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/the_hint_that_shows_with_the_editext"
android:inputType="text"
android:labelFor="@+id/edittext"
android:maxLength="15"
android:textColor="@drawable/login_activity_input_text_color" />
</android.support.design.widget.TextInputLayout>
Upvotes: 1
Reputation: 1596
Wrap the edit text with TextInputLayout
with the desired android:hint
attribute.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="StaffId"/>
</com.google.android.material.textfield.TextInputLayout>
check the official docs for more info and features
Upvotes: 1