线性布局问题 计算器布局

线性布局问题 计算器布局

问题描述:

图片说明4/09/1428560451_585625.png)

为什么没有出现第一张效果,求解
代码如下:
<?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"
    android:layout_weight="0">

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

            <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>
                 <Button android:layout_width="match_parent"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="0"></Button>
            </LinearLayout>  



        </LinearLayout>             
</LinearLayout>  

图片说明这个地方错了,改一下!

你猜~~~~~~~~~~~

图片说明

这是效果图:
代码是这样的,上边是我做实验的,麻烦指教下
android:layout_height="wrap_content" android:orientation="horizontal"
android:layout_weight="3">

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

            <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>

为何不使用网格布局,使用网格布局更为简单!