개인공부
안드로이드 : layout중복
하이후에호
2020. 7. 9. 01:19
반응형
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#9b7798"
tools:context=".MainActivity">
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="버튼1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="버튼2"/></LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="버튼3"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="버튼4"/></LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="버튼5"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="버튼6"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
.
. 새로운 내용
.
.
</LinearLayout>
<LinearLayout
.
.새로운내용
.
.
</LinearLayout>
<LinearLayout
.
.
.새로운 내용
.
</LinearLayout>
이런식으로 리니어 레이아웃안에 리니어 네이아웃을 중복해서 넣음으로서 레이아웃을 여러표현이가능하다.
하지만 상대 레이아웃처럼 복잡한 레이아웃은 표현이 어렵다 .
android:layout_weight="1" 는 레이아웃들의 비율을 나타나는 서로 같은 값을 주면 서로 동일한 크기의 레이아웃을 소유하게된다.
이처럼 리니어 레이아웃은 간단하고 쉽게 레이아웃을 구성할수가 있다.
반응형