鸿蒙初开——需分天地
上一篇我们写了helloworld的创建
鸿蒙初开,需分天地。
一个页面可以想象它为“一场表演”,多个页面则是一场“小型巡演”
这篇我们来处理页面跳转问题
在上次生成helloworld页面的基础上
(零基础的可以看看博主另一篇文章https://editor.youkuaiyun.com/md/?articleId=108585408)
这次我们使用新建一个页面进行跳转操作,并且对helloworld页面进行微调,补充一个button进去。
XML文件编写页面a:
在“Project”窗口,打开“entry > src > main > resources >
base”,右键点击“base”文件夹,选择“New > Directory”,命名为“layout”。
右键点击“layout”文件夹,选择“New > File”,命名为“main_layout.xml”。
xml中输入下列示例代码,也可以自己定义。
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:width="match_parent"
ohos:height="match_parent"
ohos:background_element="#000000">
<Text
ohos:id="$+id:text"
ohos:width="match_content"
ohos:height="match_content"
ohos:center_in_parent="true"
ohos:text="Hello World"
ohos:text_color="white"
ohos:text_size