본문 바로가기
android

[해결하기] TalkBack- focus 부분과 accessiblity 부분 처리

by arirang_ 2023. 1. 26.

Activity에 BottomNavigation이 있고 BottomNavigation을 누르면 Fragment 화면이 띄워지도록 구현하려고 했다.

TalkBack을 이용하는 프로젝트를 진행하고 있는데, 문제가 발생하여 적어본다. 

Activity 화면에 Fragment 화면이 올라오는데 Fragment 화면을 터치하면 Fragment 부분을 읽어주는 것이 아니라 아래에 깔려있는 Activity 화면의 View 들이 터치가 된다. 

일단 이러한 문제를 아래와 같이 해결하였다.

 

//BottomNav
        viewBinding.btnHtu.setOnClickListener {
            supportFragmentManager
                .beginTransaction()
                .replace(viewBinding.bottomFrameFragment.id,HowToUseFragment())
                .commitAllowingStateLoss()

            //focus 부분 되긴 되는데 효율성 떨어짐.. -> 확장 함수를 이용해서 바꿔보기
            //Home 부분을 fragment로 바꾸면 필요없어진다.
            viewBinding.bottomFrameFragment.importantForAccessibility=View.IMPORTANT_FOR_ACCESSIBILITY_YES                   //focus 되도록
            viewBinding.freeHomeScrollView.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS  //focus 안되게
            viewBinding.freeHomeTopFrame.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS    //focus 안되게
        }

 

조금 비효율적인 부분이 있긴한데 일단 해결은 하였다 조금 더 수정해보자!