[Android] EditText 키보드 타이핑 막기

James_·2022년 9월 5일
0

같은 컴포넌트끼리 include하여 만들었지만 EditText를 눌렀을 떄 바텀시트가 나와야하는 상황이 생겼다.
그래서 코드로 EditText를 설정해주었다.


        binding.includeAutoCode.et.apply {
            setRawInputType(InputType.TYPE_CLASS_TEXT)
            setTextIsSelectable(true)
            isCursorVisible = false // 타이핑할 때 커서 여부
        }

        binding.includeAutoCode.et.setOnTouchListener { view, motionEvent ->

            val inputType = binding.includeAutoCode.et.inputType
            binding.includeAutoCode.et.inputType = InputType.TYPE_NULL
            binding.includeAutoCode.et.onTouchEvent(motionEvent)
            binding.includeAutoCode.et.inputType = inputType
            mobileCarrierBottomSheetFragment.show(
                supportFragmentManager,
                mobileCarrierBottomSheetFragment.tag
            )
            true
        }

이렇게 설정해주면 EditText를 눌렀을 때 키보드가 나오지 않게 된다.

profile
Android 개발자

0개의 댓글