728x90

 

아....여러 방법으로 해봐도 잔상 같은데 남는게 해결이 안된다...

우선 코드를 기록 하고자 남긴다.

 

프래그먼트에서 사용 할 경우

        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
            }
            else{
                activity.bottom_nav.visibility = View.VISIBLE
            }
        }

엑티비티에서 사용할 경우

    homeConstrainLayout.viewTreeObserver.addOnGlobalLayoutListener {
            val r = Rect()
            homeConstrainLayout.getWindowVisibleDisplayFrame(r)
            val heightDiff: Int = homeConstrainLayout.rootView.height - (r.bottom - r.top)
            if (heightDiff > 100) {
                //enter your code here
                //bottom_nav.visibility = View.GONE
                val toast = Toast.makeText(this, "키보드 업", Toast.LENGTH_SHORT)
                toast.setGravity(Gravity.CENTER, 0, 0)
                toast.show()
            } else {
                //enter code for hid
                //bottom_nav.visibility = View.GONE
                val toast = Toast.makeText(this, "키보드 다운", Toast.LENGTH_SHORT)
                toast.setGravity(Gravity.CENTER, 0, 0)
                toast.show()
            }
        }

더 찾아 보면 방법이 나오겠지...

728x90

+ Recent posts