HarmonyOS text可以在不计算宽高快速定位到右下角吗?

Stack({ alignContent: Alignment.Center }) {  
  Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3)  
  Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac)  
}.width('100%').height(150)
  • 1.
  • 2.
  • 3.
  • 4.

这个组件的第二个text可以在不计算宽高快速定位到右下角吗?

HarmonyOS
2024-09-30 11:56:42
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

请参考以下demo:

@Entry  
@Component  
struct Index {  
  build() {  
    Scroll() {  
      Column() {  
        //Alignment.BottomEnd将第二个text定位到底部尾端  
        Stack({ alignContent: Alignment.BottomEnd }) {  
          Text('First child, show in bottom')  
            .width('90%')  
            .height('100%')  
            .backgroundColor(0xd2cab3)  
          Text('Second child, show in top')  
            .width('70%')  
            .height('60%')  
            .backgroundColor(0xc1cbac)//text组件内容定位到底部尾端  
            .textAlign(TextAlign.End)  
            .align(Alignment.BottomEnd)  
        }.width('100%').height(150)  
      }  
    }  
    .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.
分享
微博
QQ
微信
回复
2024-09-30 18:25:18


相关问题
怎么让text文本排在image里面的右下角
991浏览 • 1回复 待解决
HarmonyOS 计算多行文本布局
512浏览 • 1回复 待解决
HarmonyOS 计算富文本的实现方案
645浏览 • 1回复 待解决
HarmonyOS 怎么Page中获取窗口的
408浏览 • 1回复 待解决
如何获取屏幕,你知道
3010浏览 • 1回复 待解决
HarmonyOS RelativeContainer设置问题
299浏览 • 1回复 待解决
如何获取图片的,你知道
3184浏览 • 1回复 待解决
HarmonyOS ArkUI中设置
406浏览 • 1回复 待解决
HarmonyOS 获取图片的
492浏览 • 1回复 待解决