android学习笔记01(LinearLayout)

java类:

package tk.layout_01;



import android.os.Bundle; 

import android.app.Activity; 

import android.view.Menu;



public class MyLayout01 extends Activity {



    @Override 

    public void onCreate(Bundle savedInstanceState) { 

        super.onCreate(savedInstanceState); 

        setContentView(R.layout.my_layout01); 

    }



    @Override 

    public boolean onCreateOptionsMenu(Menu menu) { 

        getMenuInflater().inflate(R.menu.my_layout01, menu); 

        return true; 

    } 

}

XML文件:

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

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

    android:orientation= "vertical" 

    android:layout_width= "fill_parent" 

    android:layout_height= "fill_parent" 

    > 

    <TextView 

        android:id="@ id/first" 

        android:text="第一行" 

        android:gravity="center_vertical" 

        android:textSize="15pt" 

        android:background="#aa0000" 

        android:layout_width="fill_parent" 

        android:layout_height="wrap_content" 

        android:paddingLeft="10dip" 

        android:paddingTop="20dip" 

        android:paddingRight="30dip" 

        android:paddingBottom="40dip" 

        android:layout_weight="1" 

        android:singleLine="true" 

        /> 

    <TextView 

        android:id="@ id/second" 

        android:text="第二行" 

        android:gravity="center_vertical" 

        android:textSize="15pt" 

        android:background="#0000aa" 

        android:layout_width="fill_parent" 

        android:layout_height="wrap_content" 

        android:layout_weight="1" 

        /> 

</LinearLayout>

你可能感兴趣的:(LinearLayout)