当前位置: 首页 > news >正文

小学学校网站建设方案网络营销的方式与手段

小学学校网站建设方案,网络营销的方式与手段,html5网站建设 教程,wordpress设置语言【HarmonyOS】解决自定义弹框和键盘之间安全距离的问题 一、问题背景 我们在应用开发评论输入框时,常规的需求样式是:输入框view和键盘贴近,上半部展示信息区的形式,这样的设计,方便用户不割裂的去评论发言。 但是在…

【HarmonyOS】解决自定义弹框和键盘之间安全距离的问题

一、问题背景

在这里插入图片描述

我们在应用开发评论输入框时,常规的需求样式是:输入框view和键盘贴近,上半部展示信息区的形式,这样的设计,方便用户不割裂的去评论发言。

但是在使用鸿蒙提供的自定义弹框时,会发现键盘和弹框之间有个安全空隙。就算弹框布局是置底,每次显示键盘都会将弹框顶上去。
在这里插入图片描述
自定义弹框源码



struct CustomDialogExample { textValue: string inputValue: stringcontroller?: CustomDialogControllercancel: () => void = () => {}confirm: () => void = () => {}build() {Column() {TextInput({ placeholder: '', text: this.textValue }).height(60).width('90%').onChange((value: string) => {this.textValue = value}).defaultFocus(true)Text('Whether to change a text?').fontSize(16).margin({ bottom: 10 })Flex({ justifyContent: FlexAlign.SpaceAround }) {Button('cancel').onClick(() => {if (this.controller != undefined) {this.controller.close()this.cancel()}}).backgroundColor(0xffffff).fontColor(Color.Black)Button('confirm').onClick(() => {if (this.controller != undefined) {this.inputValue = this.textValuethis.controller.close()this.confirm()}}).backgroundColor(0xffffff).fontColor(Color.Red)}.margin({ bottom: 10 })}.borderRadius(10).height(px2vp(500)).offset({ x: 0, y: 16}) }
}

调用页面源码:



struct TextPage { textValue: string = '' inputValue: string = 'click me'dialogController: CustomDialogController | null = new CustomDialogController({builder: CustomDialogExample({cancel: ()=> { this.onCancel() },confirm: ()=> { this.onAccept() },textValue: $textValue,inputValue: $inputValue}),cancel: this.exitApp,autoCancel: true,onWillDismiss:(dismissDialogAction: DismissDialogAction)=> {console.info("reason=" + JSON.stringify(dismissDialogAction.reason))console.log("dialog onWillDismiss")if (dismissDialogAction.reason == DismissReason.PRESS_BACK) {dismissDialogAction.dismiss()}if (dismissDialogAction.reason == DismissReason.TOUCH_OUTSIDE) {dismissDialogAction.dismiss()}},keyboardAvoidMode: KeyboardAvoidMode.DEFAULT,alignment: DialogAlignment.Bottom,// offset: { dx: 0, dy: -20 },gridCount: 4,customStyle: false,cornerRadius: 10,backgroundColor: Color.Black})// 在自定义组件即将析构销毁时将dialogController置空aboutToDisappear() {this.dialogController = null // 将dialogController置空}onCancel() {console.info('Callback when the first button is clicked')}onAccept() {console.info('Callback when the second button is clicked')}exitApp() {console.info('Click the callback in the blank area')}build() {Column() {Button(this.inputValue).onClick(() => {if (this.dialogController != null) {this.dialogController.open()}}).backgroundColor(0x317aff)}.width('100%').margin({ top: 5 })}
}

二、解决方案

了解安全弹框的问题,需要对自定义弹框的实现有比较深刻的认识才能规避。

首先我们要搞清楚,自定义弹框的基本用法,会发现在CustomDialogExample中,build是弹框布局的具体样式的一部分,在调用页面TextPage ,其实也会设置弹框的一些样式属性,例如:customStyle。

这是系统系统的基本样式,如果customStyle该属性为false,那我们的弹框样式,只需要关心弹框内的布局,整个弹框外围是交给系统定制样式处理。

所以当我们设置customStyle该属性为true,就会发现弹框view会贴合键盘,但是整体弹框的边框都没了。

在这里插入图片描述
此时我们只需要处理边框样式和弹框背景色即可:
.borderRadius(15)
.backgroundColor(Color.White)
.borderWidth(5)

在这里插入图片描述

源码示例:

自定义弹框源码



struct CustomDialogExample { textValue: string inputValue: stringcontroller?: CustomDialogControllercancel: () => void = () => {}confirm: () => void = () => {}build() {Column() {TextInput({ placeholder: '', text: this.textValue }).height(60).width('90%').onChange((value: string) => {this.textValue = value}).defaultFocus(true)Text('Whether to change a text?').fontSize(16).margin({ bottom: 10 })Flex({ justifyContent: FlexAlign.SpaceAround }) {Button('cancel').onClick(() => {if (this.controller != undefined) {this.controller.close()this.cancel()}}).backgroundColor(0xffffff).fontColor(Color.Black)Button('confirm').onClick(() => {if (this.controller != undefined) {this.inputValue = this.textValuethis.controller.close()this.confirm()}}).backgroundColor(0xffffff).fontColor(Color.Red)}.margin({ bottom: 10 })}.width("90%").borderRadius(15).backgroundColor(Color.White).borderWidth(5).height(px2vp(500)).offset({ x: 0, y: 16})}
}

调用页面源码:



struct TextPage { textValue: string = '' inputValue: string = 'click me'dialogController: CustomDialogController | null = new CustomDialogController({builder: CustomDialogExample({cancel: ()=> { this.onCancel() },confirm: ()=> { this.onAccept() },textValue: $textValue,inputValue: $inputValue}),cancel: this.exitApp,autoCancel: true,onWillDismiss:(dismissDialogAction: DismissDialogAction)=> {console.info("reason=" + JSON.stringify(dismissDialogAction.reason))console.log("dialog onWillDismiss")if (dismissDialogAction.reason == DismissReason.PRESS_BACK) {dismissDialogAction.dismiss()}if (dismissDialogAction.reason == DismissReason.TOUCH_OUTSIDE) {dismissDialogAction.dismiss()}},keyboardAvoidMode: KeyboardAvoidMode.DEFAULT,alignment: DialogAlignment.Bottom,gridCount: 4,customStyle: true,cornerRadius: 10,backgroundColor: Color.Black})// 在自定义组件即将析构销毁时将dialogController置空aboutToDisappear() {this.dialogController = null // 将dialogController置空}onCancel() {console.info('Callback when the first button is clicked')}onAccept() {console.info('Callback when the second button is clicked')}exitApp() {console.info('Click the callback in the blank area')}build() {Column() {Button(this.inputValue).onClick(() => {if (this.dialogController != null) {this.dialogController.open()}}).backgroundColor(0x317aff)}.width('100%').margin({ top: 5 })}
}
http://www.yidumall.com/news/20165.html

相关文章:

  • 国际工程承包青岛seo排名公司
  • 网站没有做适配 怎么办怎么建个网站
  • 企业做网站哪家网站好seo推广培训课程
  • wordpress备份数据库结构抖音关键词优化排名靠前
  • 网站开发毕业设计书登封搜索引擎优化
  • wordpress怎样发邮件seo自学教程
  • oa系统使用步骤北京seo网络优化师
  • 天津做网站的网络公司页面优化算法
  • 广州模板网站怎么样优化网站seo
  • phpcms 转 wordpress tagseo英文怎么读
  • 哪些网站图片做海报好网址大全下载到桌面
  • 硬件开发平台有哪些外贸推广优化公司
  • 上海平台网站建设公司宁波网站推广公司价格
  • 福州网站外包市场营销推广策划
  • wordpress源码网站主题株洲seo快速排名
  • 雨花区区网站建设公司新闻发布最新新闻
  • 惠城网站建设有哪些seo怎么发布外链
  • 2018网站做外链优化大师免费安装下载
  • 做网站不挣钱网络优化的基本方法
  • 动力无限做网站百度推广要多少钱
  • java + jsp 如何做门户网站经营管理培训课程
  • web网站开发书籍app推广平台接单渠道
  • 个人网站icp深圳开发公司网站建设
  • 北京建设网站官网廊坊今日头条新闻
  • 怎么制作网站软件关键词的分类和优化
  • 软件工程毕业设计选题新颖厦门百度快照优化排名
  • 卧龙区网站建设哪家好百度推广官网登录
  • 哪个网站专门做二手电脑手机的html网页制作代码大全
  • 南宁做网站比较好的公司如何线上推广自己产品
  • 查询做导员的网站怎么创建网页