android线性布局(计算器ui)

图片说明
以上是效果图:
下面是我的代码,求指教:
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal">

    <EditText 
        android:id="@+id/msg" android:layout_width="match_parent"
        android:layout_height="wrap_content" android:hint="@null" />
</LinearLayout>

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal">


    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="@+string/m_c"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="m+"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="m-"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="mr"
        android:layout_weight="1"></Button>
</LinearLayout>

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal">


    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="c"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="+/-"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="/*"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="*"
        android:layout_weight="1"></Button>
</LinearLayout>

 <LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal">


    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="7"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="8"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="9"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="-"
        android:layout_weight="1"></Button>
</LinearLayout>

 <LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal">


    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="4"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="5"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="6"
        android:layout_weight="1"></Button>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="+    "
        android:layout_weight="1"></Button>
</LinearLayout>

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal"
    >

        <LinearLayout android:layout_width="wrap_content"
             android:layout_height="wrap_content" android:orientation="vertical"
             android:layout_weight="3"> 

            <LinearLayout android:layout_width="match_parent"
                 android:layout_height="match_parent" android:orientation="horizontal">
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="0"></Button>
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="0"></Button>
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="0"></Button>

            </LinearLayout>  



        </LinearLayout>             
</LinearLayout>  

最后一段,没环境,没有测试过。layout_weight注意一下,如果一个区域分2部分,其中一个要占4分之3,则那个区域要设1(越小占比越大),另一个要设3

 <LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="horizontal"
    >

        <LinearLayout android:layout_width="wrap_content"
             android:layout_height="wrap_content" android:orientation="vertical"
             android:layout_weight="1"> 

            <LinearLayout android:layout_width="match_parent"
                 android:layout_height="match_parent" android:orientation="horizontal">
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="1"></Button>
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="2"></Button>
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="3"></Button>

            </LinearLayout>  

                        <LinearLayout android:layout_width="match_parent"
                 android:layout_height="match_parent" android:orientation="horizontal">
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="0"></Button>
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="2"
                    android:text="."></Button>

            </LinearLayout>

        </LinearLayout>    
        <LinearLayout android:layout_width="wrap_content"
             android:layout_height="wrap_content" android:orientation="horizontal"
             android:layout_weight="3">
             <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" 
                    android:text="="></Button>
        </LinearLayout>         
</LinearLayout>  

你遇到啥问题了,说清楚,用weight来设置平分宽度