HarmonyOS Scroll组件下拉时上面会留空白,如何能获取图片背景色的情况下,将下拉的空白位置填充为背景色

HarmonyOS
2025-01-09 16:12:08
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

参考示例如下:

// xxx.ets
@Entry
@Component
struct Index {
  build() {
    Stack() {
      Scroll() {
        Stack({ alignContent: Alignment.TopStart }) {
          Column() {
            Text()
              .width('100%')
              .height(1000)
              .backgroundColor(Color.Brown)
          }
          .width('100%')
          .height(1000)
          .translate({
            y: -1000
          })
          .zIndex(1)
          .hitTestBehavior(HitTestMode.None)

          Column({ space: 12 }) {
            Column() {
              Image($r('app.media.startIcon'))
                .width('100%')
                .aspectRatio(1080 / 496)
                .objectFit(ImageFit.Fill)// TODO why cover not work
                .onClick(() => {
                  console.log('pqz')
                })
            }

            Column()
              .width('100%')
              .height(1000)
              .backgroundColor(Color.Red)
          }
          .zIndex(2)
        }
      }
      .width('100%')
      .height('100%')
      .scrollBar(BarState.Off)
      .align(Alignment.Top)
      .edgeEffect(EdgeEffect.Spring)
      .backgroundColor(Color.Transparent)
    }
  }
}
  • 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.
分享
微博
QQ
微信
回复
2025-01-09 19:23:16
相关问题
如何设置WebView背景色
1635浏览 • 1回复 待解决
如何设置窗口背景色
2602浏览 • 1回复 待解决
HarmonyOS Select组件背景色如何设置
595浏览 • 1回复 待解决
HarmonyOS 关于开屏背景色
600浏览 • 1回复 待解决
HarmonyOS 弹窗自带背景色
512浏览 • 1回复 待解决
Button组件如何设置渐变背景色
3748浏览 • 1回复 待解决
HarmonyOS 如何设置渐变背景色
2265浏览 • 1回复 待解决
HarmonyOS List组如何背景色设置透明
533浏览 • 1回复 待解决
JSUI按钮 toolbar背景色怎么去掉
5944浏览 • 1回复 待解决
TextInput按压态背景色如何修改
3267浏览 • 1回复 待解决
HarmonyOS 弹框背景色如何自定义图片
655浏览 • 1回复 待解决
如何设置背景色饱和度和亮度?
941浏览 • 1回复 待解决
AlertDialog没有找到设置背景色API
1231浏览 • 1回复 待解决
使用js引擎 设置dom背景色无效
1377浏览 • 0回复 待解决