안 드 로 이 드 응용 프로그램 개발 (6) 창 레이아웃

4046 단어 android
창의 레이아웃 은 layot 의. xml 파일 에서 이 루어 집 니 다.
일반적으로 eclipse 의 코드 알림 기능 Alt + / 를 사용 하여 뒤에 추가 할 속성 값 을 표시 할 수 있 습 니 다.
우선 선형 레이아웃 스타일 을 살 펴 보 겠 습 니 다: LinearLayout
<?xml version="1.0" encoding="utf-8"?>

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

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical">

    <!--      ,      ,          -->   

    <!-- 

    	android:id                ~~~~~~~~~~~~~         ID,      

    	android:text              ~~~~~~~~~~~~~            ,      string.xml      string

    	android:grivity           ~~~~~~~~~~~~~                    

    	android:textSize          ~~~~~~~~~~~~~            

    	android:background        ~~~~~~~~~~~~~             , RGB  

    	android:layout_width      ~~~~~~~~~~~~~     

    	android:layout_height     ~~~~~~~~~~~~~     

    	android:padding*          ~~~~~~~~~~~~~       

    	android:sigleLine         ~~~~~~~~~~~~~       ,              ,       ...  

    	-->    

    <TextView 

        android:id="@+id/firstText"

        android:text="first Line"

        android:gravity="center_vertical"

        android:textSize="18pt"

        android:background="#aa0000"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="10dip"

        android:paddingRight="30dip"

        android:paddingTop="20dip"

        android:paddingBottom="10dip"

        android:layout_weight="1"

        android:singleLine="true"/>

    <TextView 

        android:id="@+id/secondText"

        android:text="second Line"

        android:gravity="center_vertical"

        android:textSize="18pt"

        android:background="#00aa00"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="10dip"

        android:paddingRight="30dip"

        android:paddingTop="20dip"

        android:paddingBottom="10dip"

        android:layout_weight="2"

        android:singleLine="true"/>

    <Button

        android:id="@+id/myButton"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:layout_weight="2"

        />

</LinearLayout>

표 레이아웃 다시 보기: TableLayout
<?xml version="1.0" encoding="utf-8"?>

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

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:stretchColumns="0" >

    <!--                -->

    

    <!--     -->

    <TableRow>

        <!--           -->

    <TextView

        android:text="@string/row1_column1"

        android:background="#aa0000"

  		android:padding="3dip" />

    <TextView

        android:text="@string/row1_column2"

        android:background="#00aa00"

  		android:padding="3dip" />

    <TextView

        android:text="@string/row1_column3"

        android:background="#0000aa"

  		android:padding="3dip" />

    </TableRow>

    

        <!--     -->

    <TableRow>

        <!--           -->

    <TextView

        android:text="@string/row2_column1"

        android:background="#00aa00"

  		android:padding="3dip" />

    <TextView

        android:text="@string/row2_column2"

        android:background="#0000aa"

  		android:padding="3dip" />

    </TableRow>

</TableLayout>

좋은 웹페이지 즐겨찾기