安卓移动-作业1

实验报告

实验目的 (Experiment Purpose)

  1. Know how to create and run an Android APP
  2. Get familiar with the file structure of an Android project

实验环境 (Experiment Environment)

  1. software: java version “18.0.2”,Android Studio 2021.2.1 Patch 2
  2. Operating system:Window 10

实验内容 (Experiment content)

3.1 Experimental data

Set the string in Android/app/res/layout/value/strings.xml.

在 Android/app/res/layout/value/strings.xml中制定字符串。

<resources>
    <string name="app_name">Greeting</string>
    <string name="hello">hello</string>
    <string name="my">my</string>
    <string name="name">name</string>
    <string name="is">is</string>
    <string name="firstname">HuiTing</string>
    <string name="lastname">Ji</string>
</resources>
3.2 Experimental process

Set the layout in Android/app/res/layout/activity_main.xml.
在 Android/app/res/layout/activity_main.xml文件中设定布局。

As shown in the figure above, Greeting is generally a vertical layout, including two horizontal layouts:
The second line is a horizontal layout, including three TextViews, namely, “my”, “name”, and “is”.
The third line is a horizontal layout, including two TextViews, namely, my last name and first name.
如上图Greeting总体是垂直布局,其中包含两个水平布局:
第二行是水平布局,包含了三个TextView,分别是“my”,“name”,“is”
第三行是水平布局,包含了两个TextView,分别是我的姓和名。

3.3 Experimental results

The results display and code implementation are shown as follows:
结果展示和代码实现如下图:

3.4 Analysis
  • Set layout via , vertical layout to use statement “android:orientation=“vertical” ”, and horizontal layout to use statement “android: orientation=" horizontal "”. Layouts and layouts allow nesting.
  • Use the “android: textColor” method to set the color;
  • use the “android:gravity” method to set the text alignment, which can be set to “center”,“fill” etc.

设定布局使用<LinearLayou>,垂直布局则使用语句"android:orientation=“vertical”“,水平布局则是用语句"android:orientation=“horizonal””。布局之间允许嵌套。

设定颜色使用"android:textColor"方法;

设定文本对齐方式使用"android:gravity"方法,可以设置为"center","fill"等。

实验小结 (Summary)

My thoughts and experiences
  • The text displayed by TextView should not be directly defined in “Android: text” with double quotation marks, but should be specified in the “string.xml” file in the form of “id” and referenced with @.
  • Nesting between layouts can make the structure of the page clearer and cleaner.

TextView展示的文字不应该直接在android:text中用双引号定义,而是应该在string.xml文件中通过id形式制定字符串,在使用@进行引用。

布局之间嵌套可以使页面的构架更加清晰整洁。

Shortcomings

You can use the color attribute to define the color for a single string to make the page more beautiful.

可以对单个字符串使用color属性定义颜色,使页面更加美观。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值