본문 바로가기
안드로이드

[andorid] TextView 줄바꿈 변경 (Activity 전체)

by 아이디생성자 2023. 12. 13.

TextView는 개행 기준이 어절이여서 음절로 바꾸기 위해 replace(" ", "\u00A0")가 필요하다.

 

Activity내에 모든 TextView를 바꾸기 위해선 rootView를 돌려서 찾아주면 끝.

 

        try {
            viewDataBinding.run {
                (root as ViewGroup).allViews.forEach {
                    if (it is TextView) {
                        it.text = it.text.toString().replace(" ", "\u00A0")
                    }
                }
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }

 

 

 

댓글