android:orientation="horizontal"

뷰의 배치 방향을 설정 하는 방법 입니다.. 

main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="horizontal"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    >

<TextView  

    android:layout_width="wrap_content" 

    android:layout_height="wrap_content" 

    android:text="@string/hello"

    />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"  

android:text="@string/layout_exam"

/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/button"

android:text="입력"

/>

 

</LinearLayout>



android:orientation="horizontal" 에서 vertical 로 하면 수직 정렬이며 horizontal 일 경우네는 수평 정렬이 됩니다.

android:orientation="vertical"

  • 정렬 지정

    android:gravity="center" 를 이용하여 내용물의 정렬 방식을 지정 합니다.

     

<TextView

android:layout_width="fill_parent"

android:layout_height="fill_parent"  

android:text="@string/layout_exam"

android:gravity="center"

/>


위에 TextView 에 layout_width, layout_height 를 fill_parent 로 꽉 채운 상태에서
android:gravity="center" 를 줬습니다.. 그러니 버튼은 가려지고 layout_exam!!! 은 TextView 가운데로 정렬 되었네요..


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:gravity="center"

    >


동일하게 LiearLayout 에 android:gravity="center" 를 주면 위와 같은 효과를 볼수 있습니다.. ㅎㅎ