Linearlayout编写一个计算器界面

Activity布局文件

    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    
  
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
            android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
                    android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/search"
            
            />
                    android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/edit"
            />
                    android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/help"
            />     
   



            android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:inputType="number" 
        android:background="@android:drawable/edit_text"
        >
   


            android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
        
       
                    android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
                            
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/a"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/b"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/c"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/d"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/e"
                />
       
         
                    android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
             >
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/f"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/g"
                />


                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/h" />


                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/i"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/j"
                />
       
         
                    android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
             >
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/seven"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/eight"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/nine"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/sub"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/yu"
                />
       
         
                    android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
             >
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/four"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/five"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/six"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/plus"
                />
                            android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/con"
                />
             
     
            android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
                            android:layout_weight="4"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
                                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    >
                                            android:layout_weight="1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/one"
                        />
                                            android:layout_weight="2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/two"
                        />
                                            android:layout_weight="1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/three"
                        />
                                            android:layout_weight="1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/jian"
                        />     
               
                                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    >
                                            android:layout_weight="2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/zero"
                        />
                                            android:layout_weight="1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/dian"
                        />
                                            android:layout_weight="1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/add"
                        />
               
                
              
                    android:layout_weight="1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="@string/equal"
            />
        
     


String资源文件






    calculate
    Settings
    查看(V)
    编辑(E)
    帮助(H)
    MC
    MR
    MS
    M+
    M-
   
    CE
    C
    +-
    ^
    7
    8
    9
    /
    %
    4
    5
    6
    *
    1/x
    1
    2
    3
    -
    0
    .
    +
    =

然后运行后的效果图是这样的

Linearlayout编写一个计算器界面_第1张图片

你可能感兴趣的:(Android)