본문 바로가기
모바일 앱/Android

[Android] 안드로이드 EditText 키패드 변경하기

by 테크케찰 2020. 7. 17.

프로젝트를 진행하다 보니 웹 페이지 주소를 입력하는 키패드를 바꾸고 싶다는 생각이 들었습니다.

네이버나 다음 같은 포털 사이트 앱 상단에 있는 주소창에 주소를 입력하려고 하면 아래와 같은 키패드를 보실 수 있으실 겁니다.

또, 카카오톡과 같은 메신저 앱을 이용할 때 나타나는 키패드는 다르죠?

안드로이드 스튜디오에서 코딩을 통해 이를 지정해줄 수 있다고 합니다.

바로 xml 파일에서 EditText의 속성을 변경해주는 방법인데요, EditText의 inputType을 변경해주면 됩니다.

저는 웹 주소 검색에 적절한 키패드를 원하므로 inputType을 textUri로 설정해주면 되는데요, 코드는 아래와 같습니다.

<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textUri" />

하지만 여기서 저는 오른쪽 하단에 .com 버튼을 얻고 싶었는데, 제 코드를 실행시키니 .com 버튼이 나오지 않고 이렇게 나왔습니다.

왜 그런지 궁금해서 구글링을 해보니 디바이스에 따라서 다르게 나올 수 있다고 합니다.

https://stackoverflow.com/questions/15539429/androidinputtype-texturi-wont-enable-internet-keyboard-w-com-button

 

android:inputType="textUri" wont enable internet keyboard (w .com button)

I have an issue where I'm calling the internet keyboard with the .com button however it won't display when the keyboard is triggered. Any assistance is greatly appreciated!

stackoverflow.com

이외에도 비밀번호를 입력할 때 숨기고 싶다면 inputType을 textPassword로, 전화번호 입력을 하고 싶을 때는 phone으로 변경해주면 됩니다.

android edittext inputType이라고 구글링 해보시면 더 다양한 타입의 키패드를 찾으실 수 있으니 참고 바랍니다.

안드로이드 공식 문서 링크는 하단에 걸어놨으니 필요하신 분들은 참고 바랍니다.

 

https://developer.android.com/training/keyboard-input/style?hl=ko

 

입력 방법 유형 지정  |  Android 개발자  |  Android Developers

모든 텍스트 필드에는 이메일 주소, 전화번호 또는 일반 텍스트와 같은 특정 유형의 텍스트를 입력해야 합니다. 따라서 시스템에서 적절한 소프트 입력 방법(예: 터치 키보드)이 표시되도록 앱��

developer.android.com