fix(chat): IME 인셋 병합으로 키보드 표시 시 입력 영역 가림 문제 수정
- BaseActivity의 WindowInsets 리스너에서 systemBars와 ime 인셋의 각 방향별 최대값을 루트 패딩에 반영 - Edge-to-Edge 환경에서 하단 패딩이 키보드 높이만큼 확보되도록 개선 - ChatRoomActivity의 deprecated 설정 없이도 동작 유지
This commit is contained in:
@@ -17,6 +17,7 @@ import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import kotlin.math.max
|
||||
|
||||
abstract class BaseActivity<T : ViewBinding>(
|
||||
private val inflate: (LayoutInflater) -> T
|
||||
@@ -66,10 +67,15 @@ abstract class BaseActivity<T : ViewBinding>(
|
||||
setupView()
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
val ime = insets.getInsets(WindowInsetsCompat.Type.ime())
|
||||
|
||||
// 루트는 좌/우/하만 처리(상단은 Toolbar에 위임)
|
||||
v.setPadding(bars.left, bars.top, bars.right, bars.bottom)
|
||||
// 루트는 좌/우/하만 처리(상단은 Toolbar에 위임). IME가 등장하면 하단 패딩을 IME 높이까지 확장
|
||||
val left = max(systemBars.left, ime.left)
|
||||
val top = systemBars.top
|
||||
val right = max(systemBars.right, ime.right)
|
||||
val bottom = max(systemBars.bottom, ime.bottom)
|
||||
v.setPadding(left, top, right, bottom)
|
||||
|
||||
insets
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user