虚拟主机如何做多个网站,凡客精选带货达人,php开发企业网站教程,松江做网站公司目录 任务目标任务分析任务实施 任务目标
使用TextView、Button等实现一个计算器界面#xff0c;界面如图1所示。 图1 计算器界面效果图
任务分析
界面整体使用表格布局#xff0c;第一行使用一个TextView控件#xff0c;横跨4列#xff0c;中间4行4列#xff0c;最后一… 目录 任务目标任务分析任务实施 任务目标
使用TextView、Button等实现一个计算器界面界面如图1所示。 图1 计算器界面效果图
任务分析
界面整体使用表格布局第一行使用一个TextView控件横跨4列中间4行4列最后一行第1个控件横跨2列。
任务实施
1新建工程选择“Empty Views Activity”指定工程名为Calucator包名为cn.edu.jssvc.calucator。 2使用线性布局设计界面打开activity_mail.xml切换为Code视图将Code中的约束布局ConstraintLayout改为表格布局TableLayout并将其中的控件删除设置该TableLayout的属性android:stretchColumns“0,1,2,3”。 3将Palette区的TableRow拖到Component Tree并设置TableRow的属性android:layout_weight“1”使这5行平分整个屏幕如图2、图3所示。 图2 TableRow设置 图3 TableRow属性设置 4将TextView控件拖入第1行设置其android:layout_span属性为4即跨越4列
TextViewandroid:idid/textViewandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:layout_span4android:gravityend|bottomandroid:text0android:textSize60sp /
5将4个Button拖入第2行Button的宽度高度属性均设置为match_parentandroid:textSize设置为34sp第3行、第4行、第5行同样也是这样处理第6行只需拖入3个Button但第1个Button需要占据2列设置其android:layout_span“2”。 6最后依次修改Button的text属性完成后界面如图4所示。 图4 计算器界面运行效果图