鸿蒙Next开发-通讯录app,新建联系人页面(二)

1. 官方文档指南

布局类型名称文档指南
Row/Column线性布局https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-layout-development-linear-V5
RelativeContainer相对布局https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-layout-development-relative-layout-V5
  1. 常用组件:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-add-common-component-V5

  2. 数据库:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/data-persistence-by-rdb-store-V5

  3. 弹框组件:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-methods-action-sheet-V5

  4. 页面路由:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-routing-V5

2. 运行环境

  1. 开发工具:DevEco Studio NEXT Developer Beta2
  2. 开发语言:ArkTs+ArkUI

3. 实现步骤

  1. 首先根据UI设计稿分析页面整体布局的一个显示方向(页面排版)
    在这里插入图片描述

根据上面UI图分析,可以清楚的大致分为顶部导航栏区和内容编辑区

  1. 编写顶部导航栏
 Row() {
        Image($r('app.media.img_back')).width(24)
        Text('新建联系人')
          .padding({ left: 16 })
          .fontSize(18)
          .fontWeight(500)
      }
      .width('100%')
      .padding({ left: 16 })
      .onClick(() => {
      
      })
  1. 编写内容编辑区
Column() {
        TextInput({ placeholder: '请输入联系人姓名'})
          .copyOption(CopyOptions.LocalDevice)
          .onChange((value) => {
            this.ct_username = value
          })

        TextInput({ placeholder: '请输入手机号' })
          .type(InputType.PhoneNumber)
          .margin({ top: 10 })
          .onChange((value) => {
            this.ct_mobile = value
          })

        Button('新建联系人')
          .width('100%')
          .margin({ top: 30 })
          .onClick(() => {
          
          })

      }.alignItems(HorizontalAlign.Start)
      .width('100%')
      .padding(20)
      .margin({ top: 50 })
  1. CreateContactsPage.ets 整体代码实现过程
@Entry
@Component
struct CreateContactsPage {
  @State ct_username: string = ''
  @State ct_mobile: string = ''

  build() {

    Column() {
      Row() {
        Image($r('app.media.img_back')).width(24)
        Text('新建联系人')
          .padding({ left: 16 })
          .fontSize(18)
          .fontWeight(500)
      }
      .width('100%')
      .padding({ left: 16 })
      .onClick(() => {
      
      })

      Column() {
        TextInput({ placeholder: '请输入联系人姓名'})
          .copyOption(CopyOptions.LocalDevice)
          .onChange((value) => {
            this.ct_username = value
          })

        TextInput({ placeholder: '请输入手机号' })
          .type(InputType.PhoneNumber)
          .margin({ top: 10 })
          .onChange((value) => {
            this.ct_mobile = value
          })

        Button('新建联系人')
          .width('100%')
          .margin({ top: 30 })
          .onClick(() => {

          })

      }.alignItems(HorizontalAlign.Start)
      .width('100%')
      .padding(20)
      .margin({ top: 50 })

    }
    .height('100%')
    .width('100%')
  }
}

4. 运行效果图

在这里插入图片描述

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浩宇软件开发

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值