android中使用LinearLayout线性布局计算器
今天由于学习需要,将之前布局的计算器代码完整的展现出来给大家看看,是在android安卓平台下使用xml中的线性LinearLayout布局计算器,完整代码如下:
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:orientation=”vertical” >
<EditText
android:layout_width=”match_parent”
android:layout_height=”wrap_content” >
</EditText>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”5dp”
android:orientation=”horizontal” >
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”mc” >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”m+” >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”m-” >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”mr” >
</Button>
</LinearLayout>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”5dp”
android:orientation=”horizontal” >
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”c” >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”+/-” >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”/” >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”*” >
</Button>
</LinearLayout>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”5dp”
android:orientation=”horizontal” >
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”7″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”8″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”9″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”-” >
</Button>
</LinearLayout>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”5dp”
android:orientation=”horizontal” >
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”4″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”5″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”6″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”+” >
</Button>
</LinearLayout>
<!– 布局123 –>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”5dp”
android:orientation=”horizontal” >
<LinearLayout
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”3″
android:orientation=”vertical” >
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:orientation=”horizontal” >
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”1″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”2″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”3″ >
</Button>
</LinearLayout>
<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:orientation=”horizontal” >
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”2″
android:text=”0″ >
</Button>
<Button
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”.” >
</Button>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=”0dp”
android:layout_height=”match_parent”
android:layout_weight=”1″
android:orientation=”vertical” >
<Button
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:text=”=” >
</Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
近期评论