728x90

 //키보드 올라올때 바텀네비케이션 올라오는거 처리 부분
        //setOnFocusChangeListener 로 바텀네비게시연 하이드

        view.userSettingUdpAddressText.setOnFocusChangeListener { view, b ->
            //Variable 'b' represent whether this view has focus.
            //If b is true, that means "This view is having focus"
            if(b) activity.bottom_nav.visibility = View.GONE
            else activity.bottom_nav.visibility = View.VISIBLE
            Log.d(LOG, "setOnFocusChangeListener:${b}")
        }

        view.userSettingSerialText.setOnFocusChangeListener { view, b ->
            if(b) activity.bottom_nav.visibility = View.GONE
            else activity.bottom_nav.visibility = View.VISIBLE
            Log.d(LOG, "setOnFocusChangeListener:${b}")
        }

        view.userSettingSendIdText.setOnFocusChangeListener { view, b ->
            if(b) activity.bottom_nav.visibility = View.GONE
            else activity.bottom_nav.visibility = View.VISIBLE
            Log.d(LOG, "setOnFocusChangeListener:${b}")
        }

        var tempFlag = true
        view.fragUserSettingLiniarLayout.viewTreeObserver.addOnGlobalLayoutListener {
            val r = Rect()
            //r will be populated with the coordinates of your view that area still visible.
            view.fragUserSettingLiniarLayout.getWindowVisibleDisplayFrame(r)
            val heightDiff: Int = view.rootView.height - (r.bottom - r.top)
            if (heightDiff > 500) {
                // if more than 100 pixels, its probably a keyboard...
                activity.bottom_nav.visibility = View.GONE
                tempFlag = false
            }
            else if(tempFlag == false){
                activity.bottom_nav.visibility = View.VISIBLE
                tempFlag = true
            }
        }

        //키보드 올라올때 바텀네비케이션 올라오는거 처리 부분 END

아쉬운데로 화면 크기 비교와 에딧텍스트 부분 포커스 되는걸 같이 사용해서

잔상을 조금은 개선 할 수 있었다.

에딧텍스트만 사용하면 가끔 포커스가 되어 있는 상태에서 키보드가 내려가는 경우가 있어서

화면 크기도 같이 적용 했다.

 

에딧텍스트만 사용시 포거스 될때 바텀네이게이션이 하이드 되고

백버튼 누르면 바텀네비게시션이 나타나는 형식인데

이건 안되는 경우가 여러번 있었다.

그래서 화면 크기 변화를 이용해서 바텀네비게이션 하이드, 보여주는 부분을 한번더 처리해줬다.

 

여튼 나중에 키보드쪽 리스너가 나오면 수정 해봐야 겠다.

혹시나 더 좋은 방법 있으면 알려주세요.

728x90

+ Recent posts