1. LinearLayout 사용
맞추고 싶은 비율이 vertical인지 horizontal인지 선택
vertical일 경우: android:layout_height = 0으로 두고 android:layout_weight = 1 이런식으로 비율 맞추기
(세로로 view 비율이 맞춰진다)
horizontal일 경우: android:layout_weitght=0으로 두고 android:layout_weight = 1 이런식으로 비율 맞추기
(가로로 view 비율이 맞춰진다)
2. ConstraintLayout 사용
예를 들어 디자인 부분에 버튼 크기가 24dp가 되어있었다고 치자. 따라서 버튼의 weight와 height 값을 설정하고 margin 값을 주면 화면의 크기에 따라 버튼의 위치가 조금씩 달라진다. 이런 부분을 막기 위해서,
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
이런식으로 constraint를 넣어주고, margin 값으로 크기를 조정하면 어떤 화면 크기든간에 자연스럽게 비율이 맞춰진다!!
'android' 카테고리의 다른 글
[android] ConstraintLayout 화면 비율 유지하기 (0) | 2023.02.18 |
---|---|
[android] this와 this@ (0) | 2023.02.16 |
[해결하기] TalkBack- focus 부분과 accessiblity 부분 처리 (0) | 2023.01.26 |
[android] Drawing circle (0) | 2023.01.14 |
[fragment lifecycle] onCreatView와 onViewCreated (0) | 2023.01.05 |