鸿蒙初体验

鸿蒙初体验

线性布局

1.垂直布局

使用column

Column(){
  Text('呵。。。。。。').backgroundColor('red')
  Text('呵。。。。。。').backgroundColor('blue')
  Text('呵。。。。。。').backgroundColor('green')
  Text('将获得价值。。。。。。').backgroundColor('black')
}

效果

在这里插入图片描述

2.水平布局

使用Row

Row(){
     Text("行布局").backgroundColor("red")
     Text("行布局2").backgroundColor("blue")
     Text("行布局3").backgroundColor("#f30")
     Text("行布局4").backgroundColor("#666")
     Text("行布局5").backgroundColor("green")

   }

效果

在这里插入图片描述

组件

1.text是文本组件,用于呈现一段文本信息。

Text('hello word!')

2 按钮组件

type:ButtonType.Circle按钮的型装
stateEffect:false按钮下压的状态

  Button("圆形按钮",{type:ButtonType.Circle,stateEffect:false})  
  Button("胶囊按钮",{type:ButtonType.Capsule,stateEffect:false})
  Button("普通按钮",{type:ButtonType.Normal,stateEffect:false})

3.文本输入

placeholder 输入提示 ,text 默认值

基本输入

TextInput()
  .type(InputType.Normal)

在这里插入图片描述

密码输入

TextInput()
  .type(InputType.Password)

在这里插入图片描述

4.照片

本地资源

创建文件夹,将本地图片放入ets文件夹下的任意位置。

Image组件引入本地图片路径,即可显示图片(根目录为ets文件夹)。

Image('images/view.jpg')
.width(200)

网络资源

引入网络图片需申请权限ohos.permission.INTERNET。此时,Image组件的src参数为网络图片的链接。

Image组件首次加载网络图片时,需要请求网络资源,非首次加载时,默认从缓存中直接读取图片

Image('https://www.example.com/example.JPG')

图片插值 抗锯齿

  .interpolation(ImageInterpolation.High)

😕/www.example.com/example.JPG’)


图片插值  抗锯齿

```ts
  .interpolation(ImageInterpolation.High)
  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值