[Android]안드로이드 스튜디오Layout(레이아웃) 나누기

    안드로이드 스튜디오Layout(레이아웃) 나누기

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"           //부모에 안벗어나게 너비 최대화
    android:layout_height="match_parent"          //부모에 안벗어나게 높이 최대화
    android:background="#FFFF00"                     //배경 색상
    android:orientation="vertical"                        //레이아웃을 수직방향으로 설정
    android:weightSum="10"                             //나눌 비율의 전체 사이즈??
    tools:context=".MainActivity">
    
    <TextView                                             
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    android:textSize="28dp"
    android:textColor="#000000"
    android:background="#ccccFF"
    android:layout_weight="4"                              //전체 비율10중에 4를 차지한다.
    android:gravity="center"                                //가운데정렬??
    />
    
    <LinearLayout                                            //배경이라고 보면될거같다.
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FF9999"
    android:layout_weight="4"
    android:gravity="center"
    >
    ----------------------------------------------------------------------------------------------------------
    <FrameLayout                                            //이미지를 넣기위해 프레임 레이아웃 사용                 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Good Bye~"
    android:textSize="28dp"
    android:textColor="#000000"
    android:background="#00FF00"
    android:layout_gravity="center"
    android:layout_margin="10dp"                    //마진10
    
    />
    <FrameLayout
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_gravity="right|top"                //이미지 위치 : 오른쪽 상단
    >
    <ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/talk_bg"               //이미지 이름
    android:layout_gravity="center"
    />
    
    <TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:textColor="#FFFF00"
    android:textSize="12dp" />
    </FrameLayout>
    </FrameLayout>
    </LinearLayout>
    ---------------------------------------------------------------------------------------------------
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="2"                         //전체 공간10중 2차지
    android:background="#3333FF"
    android:gravity="center"
    android:text="Hi"
    android:textColor="#000000"
    android:textSize="28dp" />
    
    </LinearLayout>

     

    출력된 이미지

    댓글

    Designed by JB FACTORY