android学习笔记03(RelativeLayout)

java类:

package tk.layout_03;

import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu;

public class Layout03 extends Activity {

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.layout03); 
    }

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
        getMenuInflater().inflate(R.menu.layout03, menu); 
        return true; 
    } 
}

XML文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" >

    <TextView 
        android:id="@ id/label" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Type here:" 
        ></TextView> 
    <EditText 
        android:id="@ id/entry" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:background="@android:drawable/editbox_background" 
        android:layout_below="@id/label" 
        /> 
    <Button 
        android:id="@ id/ok" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/entry" 
        android:layout_alignParentRight="true" 
        android:layout_marginLeft="10px" 
        android:text="OK" 
        /> 
    <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toLeftOf="@id/ok" 
        android:layout_alignTop="@id/ok" 
        android:text="Cancel" 
        /> 
    
</RelativeLayout>
原文地址:https://www.cnblogs.com/tiankonguse/p/2610785.html