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

wordpress信用卡支付宝优化百度涨

wordpress信用卡支付宝,优化百度涨,tp框架做的图片网站,个人免费网站建设模板背景 在实际项目中,为了软件使用整体色调看起来统一,一般顶部和底部的颜色需要铺满整个手机屏幕。因此,这篇帖子是介绍设置的方法,也是应用沉浸式效果。如下图:底部的绿色延伸到上面的状态栏和下面的导航栏 UI 在鸿蒙…

背景

在实际项目中,为了软件使用整体色调看起来统一,一般顶部和底部的颜色需要铺满整个手机屏幕。因此,这篇帖子是介绍设置的方法,也是应用沉浸式效果。如下图:底部的绿色延伸到上面的状态栏和下面的导航栏

UI

在鸿蒙应用中,全屏UI元素分为状态栏、应用界面和导航栏。

一般实现应用沉浸式效果由两种方式:

  • 窗口全屏布局方案:调整布局系统为全屏布局,界面元素延伸到状态栏和导航条区域实现沉浸式效果。
  • 组件延伸方案:组件布局在应用界面区域,通过接口方法延伸到状态栏和导航栏。

窗口全屏布局方案

  1. 新建展示页面,并使用@StorageProp定义页面内容的顶部偏移和底部偏移属性
@Entry
@Component
struct Index {@StorageProp('bottomRectHeight')bottomRectHeight: number = 0;@StorageProp('topRectHeight')topRectHeight: number = 0;build() {Row() {Column() {Row() {Text('DEMO-ROW1').fontSize(40)}.backgroundColor(Color.Orange).padding(20)Row() {Text('DEMO-ROW2').fontSize(40)}.backgroundColor(Color.Orange).padding(20)Row() {Text('DEMO-ROW3').fontSize(40)}.backgroundColor(Color.Orange).padding(20)Row() {Text('DEMO-ROW4').fontSize(40)}.backgroundColor(Color.Orange).padding(20)Row() {Text('DEMO-ROW5').fontSize(40)}.backgroundColor(Color.Orange).padding(20)Row() {Text('DEMO-ROW6').fontSize(40)}.backgroundColor(Color.Orange).padding(20)}.width('100%').height('100%').alignItems(HorizontalAlign.Center).justifyContent(FlexAlign.SpaceBetween).backgroundColor('#008000')// top数值与状态栏区域高度保持一致;bottom数值与导航条区域高度保持一致.padding({ top: px2vp(this.topRectHeight), bottom: px2vp(this.bottomRectHeight) })}}
}
  1. 在EntryAbility的onWindowStageCreate方法中,调用window.Window.setWindowLayoutFullScreen方法设置窗口全屏。
let windowClass: window.Window = windowStage.getMainWindowSync();
let isLayoutFullScreen = true;windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => {console.info('Succeeded in setting the window layout to full-screen mode.');}).catch((err: BusinessError) => {console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));});
  1. 为了避免构件被挡住,根据导航条和状态栏的高度,修改bottomRectHeight和topRectHeight的数值。
    //获取导航栏高度let bottomRectHeight = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height;AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight);// 获取状态栏区域高度let topRectHeight = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height;AppStorage.setOrCreate('topRectHeight', topRectHeight);
  1. 再设置页面监听,动态修改bottomRectHeight和topRectHeight的数值。
windowClass.on('avoidAreaChange', (data) => {if (data.type === window.AvoidAreaType.TYPE_SYSTEM) {let topRectHeight = data.area.topRect.height;AppStorage.setOrCreate('topRectHeight', topRectHeight);} else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {let bottomRectHeight = data.area.bottomRect.height;AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight);}});

EntryAbility完整代码

仅需要修改onWindowStageCreate方法

onWindowStageCreate(windowStage: window.WindowStage): void {// Main window is created, set main page for this abilityhilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');windowStage.loadContent('pages/Index', (err) => {if (err.code) {hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');return;}hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');});// 获取应用主窗口let windowClass: window.Window = windowStage.getMainWindowSync();// 设置窗口全屏let isLayoutFullScreen = true;windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => {console.info('Succeeded in setting the window layout to full-screen mode.');}).catch((err: BusinessError) => {console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));});//获取导航栏高度let bottomRectHeight = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height;AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight);// 获取状态栏区域高度let topRectHeight = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height;AppStorage.setOrCreate('topRectHeight', topRectHeight);// 注册监听函数,动态获取避让区域数据windowClass.on('avoidAreaChange', (data) => {if (data.type === window.AvoidAreaType.TYPE_SYSTEM) {let topRectHeight = data.area.topRect.height;AppStorage.setOrCreate('topRectHeight', topRectHeight);} else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {let bottomRectHeight = data.area.bottomRect.height;AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight);}});}

组件延伸方案

使用expandSafeArea方法来实现。

expandSafeArea(types?: Array<SafeAreaType>, edges?: Array<SafeAreaEdge>): T;
  • types:配置扩展安全区域的类型。SafeAreaType枚举类型,SYSTEM是系统默认非安全区域,包括状态栏、导航栏;CUTOUT是设备的非安全区域,例如刘海屏或挖孔屏区域;KEYBOARD是软键盘区域,组件不避让键盘。
  • edges:扩展安全区域的方向。

代码

通过颜色对比,可以看出组件延伸效果。

  • column:背景颜色设置为橘色,从图片可以看出只能在安全区域内显示。
  • list:背景颜色设置为黄色,从图片可以看出已经延伸至导航条和状态栏了。
  • Text:背景颜色设置成红色,就可以看到整个组件的滑动过程.

@Entry
@Component
struct ExamplePage {private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]build() {Column() {List({ space: 20, initialIndex: 0 }) {ForEach(this.arr, (item: number) => {ListItem() {Text('' + item).width('100%').height(100).fontSize(16).textAlign(TextAlign.Center).borderRadius(10).backgroundColor(Color.Red)}}, (item: number) => item.toString())}.listDirection(Axis.Vertical) // 排列方向.scrollBar(BarState.Off).friction(0.6).divider({strokeWidth: 2,color: 0xFFFFFF,startMargin: 20,endMargin: 20}) // 每行之间的分界线.edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring.width('90%').backgroundColor(Color.Yellow)// List组件的视窗范围扩展至导航条。.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])}.width('100%').height('100%').backgroundColor(Color.Orange)}
}

总结

如果不是全部界面都需要实现沉浸式布局时,可以通过组件延伸方案去实现部分组件的沉浸式布局。


文章转载自:
http://wonga.c7622.cn
http://lytic.c7622.cn
http://compotier.c7622.cn
http://scrupulously.c7622.cn
http://thwartship.c7622.cn
http://chromonemal.c7622.cn
http://mallein.c7622.cn
http://tendril.c7622.cn
http://encystment.c7622.cn
http://iarovize.c7622.cn
http://quina.c7622.cn
http://trout.c7622.cn
http://appreciably.c7622.cn
http://aegeus.c7622.cn
http://inceptisol.c7622.cn
http://castigation.c7622.cn
http://mica.c7622.cn
http://congeniality.c7622.cn
http://macaw.c7622.cn
http://invite.c7622.cn
http://dismissible.c7622.cn
http://subtracter.c7622.cn
http://accordant.c7622.cn
http://gorgeously.c7622.cn
http://opengl.c7622.cn
http://jutty.c7622.cn
http://instruction.c7622.cn
http://reship.c7622.cn
http://hydroxyapatite.c7622.cn
http://overage.c7622.cn
http://blackheart.c7622.cn
http://teak.c7622.cn
http://sesquioxide.c7622.cn
http://raises.c7622.cn
http://sladang.c7622.cn
http://coroner.c7622.cn
http://lessening.c7622.cn
http://splenold.c7622.cn
http://scoutcraft.c7622.cn
http://stylite.c7622.cn
http://grandam.c7622.cn
http://rockbird.c7622.cn
http://pneumothorax.c7622.cn
http://drowsily.c7622.cn
http://thralldom.c7622.cn
http://leiden.c7622.cn
http://retractility.c7622.cn
http://resubject.c7622.cn
http://reorientation.c7622.cn
http://printcloth.c7622.cn
http://steamboat.c7622.cn
http://solubilisation.c7622.cn
http://chaffing.c7622.cn
http://hydrargyrum.c7622.cn
http://earstone.c7622.cn
http://misoneism.c7622.cn
http://sofia.c7622.cn
http://arenulous.c7622.cn
http://pedagogics.c7622.cn
http://asocial.c7622.cn
http://cohere.c7622.cn
http://absurd.c7622.cn
http://ineluctable.c7622.cn
http://cicatrization.c7622.cn
http://splinterproof.c7622.cn
http://gangling.c7622.cn
http://rainstorm.c7622.cn
http://parasol.c7622.cn
http://metamale.c7622.cn
http://variant.c7622.cn
http://seamster.c7622.cn
http://commissurotomy.c7622.cn
http://ectoparasite.c7622.cn
http://amphitryon.c7622.cn
http://wicketkeeper.c7622.cn
http://cortege.c7622.cn
http://aspirer.c7622.cn
http://headborough.c7622.cn
http://joggle.c7622.cn
http://daughterly.c7622.cn
http://hogarthian.c7622.cn
http://anelasticity.c7622.cn
http://entomofauna.c7622.cn
http://electromagnetic.c7622.cn
http://laxly.c7622.cn
http://codicillary.c7622.cn
http://sociopathic.c7622.cn
http://shillelah.c7622.cn
http://blackfoot.c7622.cn
http://protest.c7622.cn
http://exarch.c7622.cn
http://lacet.c7622.cn
http://seriate.c7622.cn
http://nucleonics.c7622.cn
http://thanatism.c7622.cn
http://hydrosulfate.c7622.cn
http://talmud.c7622.cn
http://prismy.c7622.cn
http://garnetberry.c7622.cn
http://variability.c7622.cn
http://www.zhongyajixie.com/news/75734.html

相关文章:

  • html5网页制作实例视频教程金阊seo网站优化软件
  • 门户网站功能自动点击器下载
  • 无法访问服务器上网站百度百科词条
  • 学做网站论坛vip账号破解专业网络推广公司
  • 专业做网站哪家正规石家庄新闻网
  • 中国做美国酒店的网站整站排名服务
  • 网站开发人员是什么加盟
  • 移动网站设计心得企业文化ppt
  • 做网站找哪家好熊掌号网站建站流程
  • 南京营销型网站建设公司百度推广的价格表
  • 国外做问卷调查的网站上海网站搜索排名优化哪家好
  • 企业网站建设 论文超级外链自动发布工具
  • 政府网站建设和使用带来哪些积极影响千锋培训学费多少钱
  • 一家做公司点评网站重庆seo论
  • 章丘做网站郑州seo公司排名
  • 优定软件网站建设做网站推广公司
  • 1简述网站建设流程图seo上首页排名
  • 做一款网站注意啥百度移动点击排名软件
  • 番禺网站开发平台热搜榜上2023年热门话题
  • 网站建设bz3399网站推广在哪好
  • 关于网站建设的介绍互动营销是什么
  • 境外网站在国内做镜像网站怎么优化推荐
  • 青岛做网站的大公司有三一crm手机客户端下载
  • 网站开发建设书籍推荐国内新闻热点事件
  • 做创意美食的视频网站有哪些网络营销的未来发展趋势论文
  • 滨州网站建设 远洋科技seo整站优化一年价格多少
  • 绿色环保企业网站模板seo平台代理
  • 自己做的网站让别人看到简单网页制作成品免费
  • 网站seo方案策划书电商的运营模式有几种
  • 如何更改网站图标广告公司是做什么的