计算器练习的XML布局

<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"
    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" >
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="60dip"
        android:background="@drawable/whitebg"
        android:editable="false"
        android:id="@+id/et_showview"
        android:gravity="bottom|right"
        android:textSize="20sp" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="20dip"
        android:gravity="center_horizontal"
        android:orientation="vertical" >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_clear"
                android:background="@drawable/white_btn_selector"
                android:text="C" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_del"
                android:background="@drawable/white_btn_selector"
                android:text="DEL" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_divide"
                android:background="@drawable/white_btn_selector"
                android:text="÷" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_multiply"
                android:background="@drawable/white_btn_selector"
                android:text="×" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_7"
                android:background="@drawable/white_btn_selector"
                android:text="7" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_8"
                android:background="@drawable/white_btn_selector"
                android:text="8" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_9"
                android:background="@drawable/white_btn_selector"
                android:text="9" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_minus"
                android:background="@drawable/white_btn_selector"
                android:text="-" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_4"
                android:background="@drawable/white_btn_selector"
                android:text="4" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_5"
                android:background="@drawable/white_btn_selector"
                android:text="5" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_6"
                android:background="@drawable/white_btn_selector"
                android:text="6" />
            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_pluse"
                android:background="@drawable/white_btn_selector"
                android:text="+" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical" >
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >
                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_1"
                        android:background="@drawable/white_btn_selector"
                        android:text="1" />
                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="10dip"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_2"
                        android:background="@drawable/white_btn_selector"
                        android:text="2" />
                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="10dip"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_3"
                        android:background="@drawable/white_btn_selector"
                        android:text="3" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:orientation="horizontal" >
                    <Button
                        android:layout_width="130dp"
                        android:layout_height="60dp"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_0"
                        android:background="@drawable/white_btn_selector"
                        android:text="0" />
                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="10dip"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:text="." 
                        android:id="@+id/btn_point"
                        android:background="@drawable/white_btn_selector"
                        android:textSize="20sp"/>
                </LinearLayout>
            </LinearLayout>
            <Button
                android:layout_width="60dip"
                android:layout_height="130dip"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_equal"
                android:background="@drawable/orange_btn_selector"
                android:text="=" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
时间: 2024-11-05 18:16:09

计算器练习的XML布局的相关文章

New UI-Java代码动态添加控件或xml布局

New UI-Java代码动态添加控件或xml布局  --转载请注明出处:coder-pig,欢迎转载,请勿用于商业用途! 小猪Android开发交流群已建立,欢迎大家加入,无论是新手,菜鸟,大神都可以,小猪一个人的 力量毕竟是有限的,写出来的东西肯定会有很多纰漏不足,欢迎大家指出,集思广益,让小猪的博文 更加的详尽,帮到更多的人,O(∩_∩)O谢谢! 小猪Android开发交流群:小猪Android开发交流群群号:421858269 新Android UI实例大全目录:http://blog.

仿酷狗音乐播放器开发日志二十四 选项设置窗体的实现(附328行xml布局源码)

转载请说明原出处,谢谢~~ 花了两天时间把仿酷狗的选项设置窗体做出来了,当然了只是做了外观.现在开学了,写代码的时间减少,所以整个仿酷狗的工程开发速度减慢了.今天把仿酷狗的选项设置窗体的布局代码分享出来,给学习duilib布局的朋友做个demo.现在编写的仿酷狗选项设置窗体和原酷狗的窗体不细看几乎看不出差别,控件的布局位置和原酷狗最多只有几个像素的位置差别. 先来看一下原酷狗的选项设置窗体的其中一个页面: 如果还不太会布局的朋友可以先看我前些日子写的关于duilib布局的博客<duilib各种布

第五篇:在SOUI中使用XML布局窗口

窗口布局的概念 每一个UI都是由大量的界面元素构成的,在Windows编程,这些界面元素的最小单位通常称之为控件. 布局就是这些控件在主界面上的大小及相对位置. 传统的布局一般使用一个4个绝对坐标来定义一个控件在主窗口的位置.对于窗口是固定大小的界面来说,这种方式是最简单有效的. 然而问题在于在Windows系统上编程,基本上很少有程序的窗口是固定大小的,用户希望它的窗口能够随时调整大小.调整大小后界面里的控件还能够按照一定的规则进行重排. 我自己最讨厌的就是在WM_SIZE里重排控件位置. 随

Android中将xml布局文件转化为View树的过程分析(上)

有好几周没写东西了,一方面是因为前几个周末都有些事情,另外也是因为没能找到好的写作方向,或者说有些话题 值得分享.写作,可是自己积累还不够,没办法只好闷头继续研究了.这段时间一边在写代码,一边也在想Android中 究竟是如何将R.layout.xxx_view.xml这样的布局文件加载到Android系统的view层次结构中的(即我们常说的view树). 这期间一方面自己研究了下源码,另一方面也在网上搜索了下相关文章,发现了2篇很不错的同主题文章,推荐给大家: http://blog.csdn

Android中将xml布局文件转化为View树的过程分析(下)-- LayoutInflater源码分析

在Android开发中为了inflate一个布局文件,大体有2种方式,如下所示: // 1. get a instance of LayoutInflater, then do whatever you want LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // 2. you're in some View class, then jus

简析静态xml布局如何通过动态代码实现

先看一下xml代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/contentView" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android

Android中measure过程、WRAP_CONTENT详解以及xml布局文件解析流程浅析(上

                                                                                                                                               本文原创, 转载请注明出处:http://blog.csdn.net/qinjuning 在之前一篇博文中<<Android中View绘制流程以及invalidate()等相关方法分析>>,简单的阐述

xml布局自定义SurfaceView模板

package com.dream.apm; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; import android.util.Log; import andr

Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析

转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PARENT/FILL_PARENT属性的原理说明 xml布局文件解析成View树的流程分析. 希望对大家能有帮助.- - 分析版本基于Android 2.3 . 1.WRAP_CONTENT.MATCH_PARENT/FILL_PARENT 初入Android殿堂的同学们,对这三个属性一定又爱又恨.爱的是使