문제 상황
peek_height를 설정한 BottomSheet가 AVD 상에서 잘 작동하는 것을 확인했으나, 실제 기기인 갤럭시 노트10(안드로이드 Q)에서는 BottomSheet가 다 보이는, 즉 peek_height 속성의 값이 적용되지 않는 문제가 있었다. 심지어 숨겨지지도 않았다.
해결 방법
안드로이드 Q에서부터 BottomSheet 제스처와 시스템 네비게이션 제스처와의 충돌을 방지하기 위해 GestureBottomInserts가 default behavior로 설정했기 때문이라고 한다. API29에서도 BottomSheet가 동일하게 동작하기 윈한다면 이를 무시하는 속성인 "gestureInsetBottomIgnored"를 trure로 설정하면 된다. XML과 프로그래밍 코드 상에서 모두 가능하다.
아래는 Java 설정 코드 예제이다.
BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(bottomSheetBehaviorView);
behavior.setGestureInsetBottomIgnored(true);
XML로 설정하는 방법은 아래 참고한 글에 나와있다. style.xml로 설정하는 방법인데, 나는 코드로 설정하는 것이 더 편해서 위 코드로 설정해서 해결하였다.
*참고한 글
'Android App > Tip' 카테고리의 다른 글
[Android/Tip] Elevation으로 생긴 그림자 없애기(Remove elevation shadow) (0) | 2020.09.05 |
---|---|
[Android/Tip] EditText 입력 텍스트 최대 길이 제한하기 (Limit maximum text length of EditText) (0) | 2020.09.01 |