电子产业一站式赋能平台

PCB联盟网

搜索
查看: 731|回复: 0
收起左侧

北向应用:Car页面布局与跳转测试

[复制链接]

2607

主题

2607

帖子

7472

积分

高级会员

Rank: 5Rank: 5

积分
7472
发表于 2020-12-30 17:57:02 | 显示全部楼层 |阅读模式
北向应用:Car页面布局与跳转测试, 显示效果: 点击“点击了解更多”进入下一个页面 代码如下: 第一个页面的布局 <?xml version=“1.0“ encoding=“utf-8“?>

<Directionallayout

     xmlns:ohos=“http://schemas.huawei.com/res/ohos“

     ohos:height=“match_parent“

     ohos:width=“match_parent“

     ohos:orientation=“vertical“>



     <DirectionalLayout

         ohos:width=“match_parent“

         ohos:weight=“1“>

         <Text

             ohos:width=“match_content“

             ohos:height=“match_content“

             ohos:text=“ 蛟龙腾飞“

             ohos:text_size=“20fp“

             ohos:top_margin=“40px“

             ohos:left_margin=“80px“/>



     </DirectionalLayout>

     <DirectionalLayout

         ohos:width=“match_parent“

         ohos:weight=“4“

         ohos:orientation=“horizontal“>

         <DirectionalLayout

             ohos:height=“match_parent“

             ohos:weight=“1“>

             <Image

                 ohos:width=“526px“

                 ohos:height=“504px“

                 ohos:top_margin=“-50px“

                 ohos:left_margin=“20px“

                 ohos:image_src=“$media:index20“/>

         </DirectionalLayout>

         <DirectionalLayout

             ohos:height=“match_parent“

             ohos:weight=“2“>

             <Text

                 ohos:width=“match_content“

                 ohos:height=“match_content“

                 ohos:multiple_lines=“true“

                 ohos:text=“ 带你从传统的互联网、移动互联网时代

                                跳转到万物互联的智能世界!

                                                         ohos:text_size=“20fp“

                 ohos:top_margin=“20px“

                 ohos:left_margin=“60px“/>

             <Button

                 ohos:id=“$+id:jltfbutton“

                 ohos:width=“match_content“

                 ohos:height=“match_content“

                 ohos:text=“ 点击了解更多“

                 ohos:text_size=“25fp“

                 ohos:top_margin=“60px“

                 ohos:left_margin=“650px“

                 ohos:text_color=“red“/>

         </DirectionalLayout>



     </DirectionalLayout>



</DirectionalLayout> 第二个页面的布局 <?xml version=“1.0“ encoding=“utf-8“?>

<DirectionalLayout

     xmlns:ohos=“http://schemas.huawei.com/res/ohos“

     ohos:height=“match_parent“

     ohos:width=“match_parent“

     ohos:orientation=“vertical“>



     <DirectionalLayout

         ohos:width=“match_parent“

        ohos:weight=“1“

         >

         <Text

             ohos:width=“match_content“

             ohos:height=“match_content“

             ohos:text=“ 蛟龙腾飞“

             ohos:text_size=“20fp“

             ohos:top_margin=“40px“

             ohos:left_margin=“80px“/>



     </DirectionalLayout>

     <DirectionalLayout

         ohos:width=“match_parent“

         ohos:weight=“4“

         ohos:orientation=“horizontal“>

         <DirectionalLayout

             ohos:height=“match_parent“

             ohos:weight=“1“>

             <Image

                 ohos:width=“357px“

                 ohos:height=“360px“

                 ohos:top_margin=“60px“

                 ohos:left_margin=“100px“

                 ohos:image_src=“$media:index4“/>

         </DirectionalLayout>

         <DirectionalLayout

             ohos:height=“match_parent“

             ohos:weight=“2“>

             <Text

                 ohos:width=“match_content“

                 ohos:height=“match_content“

                 ohos:multiple_lines=“true“

                 ohos:text=“ 你好,欢迎来到鸿蒙时代!

                                                    ohos:text_size=“20fp“

                 ohos:top_margin=“60px“

                 ohos:left_margin=“10px“/>

         </DirectionalLayout>



     </DirectionalLayout>



</DirectionalLayout> 然后绑定布局进行跳转 Button button = (Button) findComponentById(ResourceTable.
Id_jltfbutton);



button.setClickedListener(new Component.ClickedListener() {

     @Override

     public void onClick(Component component) {



         present(new jltftabletSlice(),new Intent());

     }





});
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


联系客服 关注微信 下载APP 返回顶部 返回列表