Skip to content

Instantly share code, notes, and snippets.

@mrsid96
Created May 30, 2018 12:02
Show Gist options
  • Save mrsid96/e42ddae05a16f5f0368c7ea9bc3cab29 to your computer and use it in GitHub Desktop.
Save mrsid96/e42ddae05a16f5f0368c7ea9bc3cab29 to your computer and use it in GitHub Desktop.
Textarea in android
xml
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/shipper_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/shipper_field"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@drawable/text_layout_stroke_normal"
android:gravity="top"
android:hint="HELLO"
android:inputType="textMultiLine"
android:overScrollMode="always"
android:padding="15dp"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" />
</android.support.design.widget.TextInputLayout>
java
edittext.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus) {
GradientDrawable drawable = (GradientDrawable)edittext.getBackground();
drawable.setStroke(2, Color.RED);
edittext.setHintTextColor(Color.RED);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment