HarmonyOS 如何设置App实现字体统一放大的老年模式,并且可以来回切换正常模式和大字模式

HarmonyOS 如何设置App实现字体统一放大的老年模式,并且可以来回切换正常模式和大字模式

HarmonyOS
2024-08-10 12:26:18
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

可以参考以下demo 使用Slider或者button来控制字体的放大和缩小

@Entry 
@Component 
struct Pagebutton { 
  @State imagewidth: number = 30; 
  @State fontwight: number = 30; 
  build() { 
 
    Column() { 
      Row(){ 
        Text($r('app.string.text')).fontSize(this.fontwight) 
        TextInput({placeholder:$r('app.string.image_width'),text:this.imagewidth.toString()}) 
          .type(InputType.Number) 
          .onChange(value=>{ 
            this.fontwight=parseInt(value) 
          }).backgroundColor('#fff') 
      }.justifyContent(FlexAlign.SpaceBetween).width('100%').padding({ 
        left:10, 
        right:10 
      }) 
      Divider().width('91%') 
      Row({space:10}){ 
        Button('点击增加字体大小').onClick(()=>{ 
 
          this.fontwight+=10 
        }) 
        Button('点击减少字体大小').onClick(()=>{ 
          this.fontwight-=10 
        }) 
      }.width('100%') 
      .justifyContent(FlexAlign.SpaceEvenly) 
      .margin({ 
        top:50 
      }) 
 
      Row(){ 
 
        Slider({ 
          min:0, 
          max:100, 
          value:this.imagewidth, 
          step:10, 
          style:SliderStyle.OutSet, 
          direction:Axis.Horizontal, 
          reverse:false 
        }).showTips(true).blockColor('#36d').onChange(value=>{ 
          console.log('value',value) 
          this.imagewidth=Math.trunc(value)//取整 
          console.log(typeof value) 
        }).trackThickness(10).width('100%') 
      }.margin({ 
        top:50 
      }) 
 
    } 
    .width('100%') 
 
  } 
}
  • 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.
分享
微博
QQ
微信
回复
2024-08-10 17:25:08
相关问题
适老化模式字体放大咨询
1157浏览 • 1回复 待解决
app适配深色浅色切换模式
2621浏览 • 1回复 待解决
应用如何切换夜间模式
2121浏览 • 1回复 待解决
HarmonyOS分屏幕模式小窗口模式适配
1851浏览 • 1回复 待解决
HarmonyOS 如何设置固定浅色模式
594浏览 • 1回复 待解决
HarmonyOS 浅色模式与深色模式
884浏览 • 1回复 待解决
HarmonyOS app如何禁用深色模式
927浏览 • 1回复 待解决
HarmonyOS 组件切换深色模式不生效
1258浏览 • 1回复 待解决
如何设置Web组件深色模式
1075浏览 • 1回复 待解决