LinearLayout 을 잘만 사용해도 어느 정도 디자인을 꾸밀 수 있다.
1. LinearLayout xml 생성
<LinearLayout xmlns : android = "http://schemas.android.com/apk/res/android"
android : layout_width = "match_parent"
android : layout_height = "match_parent"
android : paddingLeft = "16dp"
android : paddingRight = "16dp"
android : orientation = "horizontal"
android : gravity = "center">
<!-여기에 다른 위젯 또는 레이아웃 태그를 포함합니다. 이것들은 고려됩니다
선형 레이아웃의 "자식보기"또는 "자식"->
</ LinearLayout>
XML attributes
2. LinearLayout 안에 LinearLayout 넣기
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FF0000">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#0000FF">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#008000">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#FFFF00"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#0000FF"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#008000"
>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Button1"
/>
<ImageView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/img">
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<TextView
android:id="@+id/txt1"
android:layout_width="126dp"
android:layout_height="match_parent"
android:text="Hello"
android:textColor="#FF0000"
android:textSize="45dp">
</TextView>
<TextView
android:id="@+id/txt2"
android:layout_width="150dp"
android:layout_height="match_parent"
android:text="World"
android:textColor="#0000FF"
android:textSize="40dp">
</TextView>
</LinearLayout>
</LinearLayout>
developer.android.com/guide/topics/ui/layout/linear?hl=ko
728x90
반응형
'Flutter > Android' 카테고리의 다른 글
[안드로이드] 6. Activity and Intent (0) | 2021.01.25 |
---|---|
[안드로이드] 5. Option Menu (0) | 2021.01.25 |
[안드로이드] 4. EditText와 TextView를 이용해서 간단한 계산기 만들기. (0) | 2021.01.25 |
[안드로이드] 2. Buttons (0) | 2021.01.24 |
[안드로이드] 1. Toast Message 와 Log Message (0) | 2021.01.24 |