티스토리 뷰

728x90

root layout 에 아래 두 코드를 삽입하세요.

 

android:focusable="true"
android:focusableInTouchMode="true"

 

위 코드는 EditText 에 포커스가 자동으로 가는 것을 방지해 줍니다.

실행하는 뷰에 EditText 가 있다면 해당 EditText 로 포커스가 이동 되는 것은 기본값이기 때문입니다.

EditText 로 포커스가 이동되면 자동으로 키보드가 올라옵니다.

 

아래에 참고하실 전체 코드를 첨부해 놓을게요.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:context=".MainActivity">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

728x90

'android' 카테고리의 다른 글

android web view settings  (0) 2022.05.23
how to remove title from android app  (0) 2022.05.23
그라데이션 효과 적용하는 방법  (0) 2022.05.22
play kotlin  (0) 2022.05.22
how to get fcm token  (0) 2022.05.21
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
글 보관함