美文网首页
常用布局效果2024-06-17

常用布局效果2024-06-17

作者: iOS打怪升级 | 来源:发表于2024-06-16 16:00 被阅读0次
  • 左动右静:利用Blank 的自动填充空白功能,以及Flex 的弹性功能
@Entry
@Component
struct BlankExample {
  build() {
    Column() {
      Flex() {
        Text('BluetoothB').fontSize(18)
          .backgroundColor(Color.Red)
        Blank()
          .backgroundColor(Color.Green)
        Toggle({ type: ToggleType.Switch, isOn: true })
          .backgroundColor(Color.Red)
      }.backgroundColor(Color.Yellow).borderRadius(15).padding(16).width('100%')
    }.backgroundColor(0xEFEFEF).padding(20).width('100%')
  }
}
效果: image.png
  • 带标签换行环绕
@Styles style1 () {
    .width('100%')
    .height(100)
    .backgroundColor(Color.Pink)
    .padding({left:16, right:16, top:0,bottom:0})
    .margin({top:4,bottom:4})
    .borderRadius(10)
  }

  @Builder Card1 (){
    Column() {
      Flex() {
        // 左边的固定标签
        Stack() {
          Text('标签1')
            .fontSize(12)
              // .margin({ left: 10}) // 标签和标题之间的最小间距
            .foregroundColor(Color.Blue)
            // .backgroundColor(Color.Red)
            .margin({top:3})
            .padding({left:3,right:3, top:2, bottom:2})
            .borderColor(Color.Black)
            .borderWidth(1)
          Text('标题和图标s标题和图标标题和图标标题和图标dfadsfsdfasadf的')
            .fontSize(16)
            .lineHeight(24)
            .textAlign(TextAlign.Start)
            .foregroundColor(Color.Red)
            .textIndent(3*12+5)

            .textOverflow({overflow:TextOverflow.None})

        }
        .width('100%')
        .align(Alignment.TopStart)
        .backgroundColor(Color.Yellow)

        // 右边的图标
        Image($r('app.media.icon'))
          .backgroundColor(Color.Red)
          .width(20)
          .height(24)
          .margin({ left: 10 }) // 图标和标题之间的最小间距
      }
      .backgroundColor(Color.Green)
      // .justifyContent(FlexAlign.Start)
      // .width('100%')
      .height('100')
      // .alignItems(VerticalAlign.Top)
      // .justifyContent(FlexAlign.SpaceBetween)
      .padding({ left: 10, right:10,top:10 }) // 左右边距
      .borderRadius(10)
    }
    .style1()
  }

  build() {
    if (this.card1)  this.Card1()
    else this.Card2()
  }

使用:
主页面:
 build() {
    Column() {
      HQLCIndexTest()
      HQLCIndexTest()
    }
    .width('100%')
    .height('100%')
    .backgroundColor('#f0f0fe')
  }

image.png

相关文章

  • 经典页面布局学习

    总结几种常用的页面布局 上中下布局 页面运行效果: 左右两栏布局 页面运行效果: 左右两栏纯浮动实现宽度固定,不能...

  • 使用代码动态增删布局(2018.8重编版)

    目录 效果图前言布局文件实现最后 效果图 不多废话, 先上图, 有兴趣再看下去: 前言 用代码增删布局还是很常用的...

  • LinearLayout android:layout_weig

    LinearLayout,很常用的一种布局,当在使用这种布局方式时,为了达到较好的屏幕适配效果,可以选择使用and...

  • 基本布局之RelativeLayout 相对布局

    RelativeLayout 相对布局, 是非常常用的布局. 它可以让控件出现在任何位置. 先来一个实例: 效果:...

  • 头部可缩放的布局 | ScalingLayout

    该布局支持布局头部可缩放,在一些资讯类的APP会经常用到。效果图 添加依赖 在xml布局添加控件 Java代码设置...

  • CSS布局

    布局方式 一列布局 效果: 二列布局 效果: 三列布局 效果: 混合布局 效果: 布局分析 1、标准流 常见块级元...

  • Android纯代码编写布局

    概述:android动态效果免不了需要编写代码布局,所以记录一下常用布局组件的编写方式。 一、编写LinearLa...

  • ListView 与 RecyclerView 简单对比

    RecyclerView 与 ListView 的主要区别:布局效果对比常用功能与API对比在Android L引...

  • GeekBand-第二周分享

    五大布局: 【常用】LinearLayout 线性布局 RelativeLayout 相对布局 【不常用】Fram...

  • TabLayout +ViewPager+Fragment 组合

    1. tabLayout的使用 布局: 或者使用代码添加: 效果图: 常用属性: 显示模式可滑动: app:tab...

网友评论

      本文标题:常用布局效果2024-06-17

      本文链接:https://www.haomeiwen.com/subject/upjtcjtx.html