鸿蒙界面开发(四):支付宝首页开发实战

利用了层叠布局和一个scroll滚动组件。

包括底部导航、顶部导航、主体的滚动窗口。

主体的滚动窗口又包括一个快捷导航栏和一个导航窗口、以及主体部分

javascript 复制代码
import text from '@ohos.graphics.text';

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';
  //支付宝首页·
  build() {
    Stack({alignContent:Alignment.Bottom}){
      //顶部导航
      Stack({alignContent:Alignment.Top}){
        Row(){
          Column(){
            Text('北京')
              .fontSize(18)
              .fontColor('#fff')
            Text('晴 37C')//摄氏度的符号怎么打
              .fontSize(12)
              .fontColor('#fff')
            Image($r('app.media.zfb_head_down'))
              .width(12)
              .fillColor('#fff')
              .position({
                x:40,
                y:0
              })

          }

          Row(){
            Image($r('app.media.zfb_head_search'))
              .width(20)
              .fillColor('#666')
              .margin({left:5, right:5})
            Text('北京交通一卡通')
              .layoutWeight(1)
            Text('搜索')
              .width(55)
              .fontColor('#5b73de')
              .fontWeight(700)
              .textAlign(TextAlign.Center)
              .border({
                width:{left:1},
                color:'#ccc'
              })
          }.height(32)
          .layoutWeight(1)//自适应屏幕
          .backgroundColor('#fff')
          .borderRadius(5)
          .margin({left:25, right:12})

          Image($r('app.media.zfb_head_plus'))
            .width(30)
            .fillColor('#fff')
        }.width('100%')
        .height(60)
        .backgroundColor('#5b7fde')
        .zIndex(666)
        .padding({left:10,right:10})
        //Column和Row默认都没有滚动的效果
        // Column(){
        //
        // }
        //利用Scroll实现主体滚动部分
        Scroll(){
          Column(){
            //top快捷按钮
            Row(){
              Column(){
                Image($r('app.media.zfb_top_scan'))
                  .width(36)
                  .fillColor('#fff')
                Text('扫一扫')
                  .fontColor('#fff')
              }.layoutWeight(1)
              Column(){
                Image($r('app.media.zfb_top_pay'))
                  .width(36)
                  .fillColor('#fff')
                Text('收付款')
                  .fontColor('#fff')
              }.layoutWeight(1)
              Column(){
                Image($r('app.media.zfb_top_travel'))
                  .width(36)
                  .fillColor('#fff')
                Text('出行')
                  .fontColor('#fff')
              }.layoutWeight(1)
              Column(){
                Image($r('app.media.zfb_top_card'))
                  .width(36)
                  .fillColor('#fff')
                Text('卡包')
                  .fontColor('#fff')
              }.layoutWeight(1)
            }.width('100%')
              .padding({top:5,bottom:15})
              .backgroundColor('#5b7fde')

            //主体导航区
            Column({space:10}){
              Row(){
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
              }.width('100%')
              Row(){
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
              }.width('100%')
              Row(){
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
              }.width('100%')
            }
              .width('100%')
              .borderRadius({
                topLeft:20,
                topRight:20
              })
              .padding(10)
              .backgroundColor(Color.White)

            //产品区
            Row({space:5}){
              Image($r('app.media.zfb_pro_pic1'))
                .layoutWeight(1)
              Image($r('app.media.zfb_pro_pic2'))
                .layoutWeight(1)
              Image($r('app.media.zfb_pro_pic3'))
                .layoutWeight(1)
            }.backgroundColor(Color.White)
            Column(){
              Image($r('app.media.zfb_pro_list1'))
                .width('100%')
              Image($r('app.media.zfb_pro_list2'))
                .width('100%')
            }.backgroundColor(Color.White)
          }.width('100%')
          .backgroundColor('#5b73de')

        }.width('100%')
        .padding({top:60,bottom:60})
      }.width('100%')
      .height('100%')//占用全部空间

      //底部导航栏
      Row(){
        Column(){
          Image($r('app.media.zfb_tab_home'))
            .width(35)

          // Text('首页')
          // .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_money'))
            .width(28)

          Text('理财')
            .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_life'))
            .width(28)

          Text('生活')
            .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_chat'))
            .width(28)

          Text('消息')
            .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_me'))
            .width(28)

            .margin({bottom:2})
          Text('我的')
            .fontSize(12)
        }.layoutWeight(1)
      }
      .width('100%')
      .height(60)
      .backgroundColor(Color.White)
    }.width('100%')
    .height('100%')
  }
}
相关推荐
鹤归时起雾.10 分钟前
CSS属性继承与元素隐藏全解析
前端·css
火星数据-Tina16 分钟前
让电竞数据实时跳动:Spring Boot 后端 + Vue 前端的完美融合实践
前端·vue.js·spring boot
fruge26 分钟前
前端可视化家庭账单:用 ECharts 实现支出统计与趋势分析
前端·javascript·echarts
IT_陈寒1 小时前
Vue3性能优化实战:5个被低估的Composition API技巧让你的应用快30%
前端·人工智能·后端
Lethehong1 小时前
华为CANN异构计算架构技术分析报告:架构、优势与应用实践
人工智能·华为·架构
嘻嘻哈哈猿人1 小时前
从 0 到 1 实现一个支持 @ 提及用户的输入框组件(Vue3 实战)
前端·vue.js
白茶三许1 小时前
关于Flutter版本过低导致鸿蒙虚拟机启动失败的问题解决
flutter·开源·harmonyos·openharmony
东土也1 小时前
Vue 项目 Nginx 部署路径差异分析与部署指南
前端
云枫晖1 小时前
Vue3 响应式原理:手写实现 ref 函数
前端·vue.js
合作小小程序员小小店1 小时前
web网页开发,在线%宠物销售%系统,基于Idea,html,css,jQuery,java,ssh,mysql。
java·前端·数据库·mysql·jdk·intellij-idea·宠物