HarmonyOS 页面底部流出安全区域

import { BuilderNameConstants, RouterModule, RouterNameConstants } from '@ohos/routermodule/Index';
import { CommonUtils, NavbarView, ScaffoldStyleConstants } from '@ohos/scaffold/Index';
import { CommonInputStyle, CommonLineStyle, NextButtomStyle } from '../../commmon/LoginComponentStyle';
import StyleConstants from '../../commmon/constants/StyleConstants';
import { MatchInputFilterUtils } from '@ohos/common/Index';

// desc:找回账号step1-输入待找回手机号
RouterModule.registerBuilder(BuilderNameConstants.LOGIN_FIND_ACCOUNT_STEP1, wrapBuilder(harBuilder))

@Builder
export function harBuilder(value: object) {
  NavDestination() {
    Column() {
      NavbarView({ title: "找回账号", onBackClick: () => {
          RouterModule.pop()
        }
      })
      View()
    }.width('100%')
    .height('100%')
    .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
  }
  .hideTitleBar(true)
  .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
}

@Entry
@Preview
@Component
export struct View {
  //待找回手机号
  @State phoneNumber: string = '';

  build() {
    Column() {
      //手机号输入框
      TextInput({ placeholder: $r('app.string.input_old_number'), text: "18583961321" })
        .attributeModifier(new CommonInputStyle(StyleConstants.INPUT_PHONE_LENGTH, InputType.Number, 64,
          TextAlign.Center))
        .onChange((value: string) => {
          this.phoneNumber = value;
        })
      //底部按钮
      Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.End }) {
        Column() {
          //分割线
          Line().attributeModifier(new CommonLineStyle());
          // FindAccountBottomView({callback:this.nextBtnClick});
          Button($r('app.string.next_step'), { type: ButtonType.Normal, stateEffect: true })
            .enabled(this.phoneNumber !== '')
            .attributeModifier(new NextButtomStyle())
            .onClick(() => {
              if (!MatchInputFilterUtils.photoMatch(this.phoneNumber)) {
                CommonUtils.showToastContent($r('app.string.phone_number_error'));
                return
              }
              RouterModule.pushRouter({
                builderName: BuilderNameConstants.LOGIN_FIND_ACCOUNT_STEP2,
                param: Object({
                  phoneNumber: this.phoneNumber,
                })
              })
            })
        }
      }.layoutWeight(1)
    }.backgroundColor($r('app.color.scaffold_fg_light'))
    .width(ScaffoldStyleConstants.FULL_PARENT)
    .height(ScaffoldStyleConstants.FULL_PARENT)
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
HarmonyOS
2025-01-09 15:48:01
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

页面底部留出安全区域是因为在代码中使用了expandSafeArea属性,expandSafeArea属性允许组件扩展其安全区域。通过设置该属性,组件可以突破安全区域的限制,将其绘制内容扩展到安全区外。

参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-expand-safe-area-V5

分享
微博
QQ
微信
回复
2025-01-09 18:53:09
相关问题
HarmonyOS 安全区域出错
790浏览 • 1回复 待解决
HarmonyOS 安全区域失效
755浏览 • 1回复 待解决
HarmonyOS 安全区域问题
977浏览 • 1回复 待解决
HarmonyOS WebView安全区域问题
604浏览 • 1回复 待解决
HarmonyOS scroll安全区域问题
844浏览 • 1回复 待解决
HarmonyOS 设置安全区域不生效
843浏览 • 1回复 待解决
HarmonyOS 如何获取手机安全区域高度
791浏览 • 1回复 待解决
HarmonyOS 视频组件无法扩展其安全区域
1075浏览 • 1回复 待解决
关于屏幕安全区域的问题咨询
1084浏览 • 1回复 待解决