Android Studio
[Android][Java]editText에 maxLines="1" 적용
코린이탈출기
2022. 9. 23. 15:22
728x90
사용자에게 텍스트 입력 줄을 제한하기 위해 maxLines을 사용한다면 inputType도 같이 사용해야 한다.
1. maxLines="1" 만 사용한 경우
1줄을 다 적어도 그 다음 줄로 개행되어 여전히 텍스트가 적힌다.
2. maxLines="1" 과 inputType 을 같이 사용한 경우
1줄로만 이어 적히는 것을 확인할 수 있다.
이 때는 maxLines에 1이상의 숫자를 설정해 놓아도 1줄로만 입력된다.
> 예제 코드
더보기
<EditText
android:id="@+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:padding="15dp"
android:maxLines="1"
android:hint="email"
android:inputType="textEmailAddress" />
(참고)
https://stack07142.tistory.com/112
Android - EditText maxLines 적용이 안되는 현상
Android - EditText maxLines 적용이 안되는 현상 EditText 생성 후 EditText를 1줄로만 사용하기 위해서는 다음과 같은 속성을 주시면 됩니다. android:maxLines="1" 그러나 텍스트 입력 후 엔터 버튼을 누르면 여
stack07142.tistory.com
728x90