728x90
반응형
레이아웃에 포함된 하위 컴포넌트들의 비율을 설정해 놓고 크기 변동에 따라 동적으로 변화시키기 위함
1. 예로 아래와 같은 형태로 만들어 보고자 한다면
아래처럼 해보면 됨.
Text 대신 ImageView로 하면 이미지로 설정가능하겠음.
2.상위에 weigthSum을 설정하고 그 하위에서 비율을 고려해서 weight를 설정
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="<">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="8"
android:text="Title">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="|"
android:layout_weight="1"
>
</TextView>
</LinearLayout>
728x90
반응형
'Etc > android' 카테고리의 다른 글
[android] kotlin dp to pixel (textview 에 dp 적용) (0) | 2023.07.27 |
---|---|
[android] rounded corner 적용하기 (shape xml 만들기) (0) | 2023.07.19 |
[android] VCS -> git push (0) | 2023.07.05 |
[android] splash 화면 만들기 (0) | 2023.06.29 |
[android] wifi 디버깅 모드 활성화 (0) | 2023.06.28 |