以下button,内包含图片和文字,现在需求是图片后间隔5vp跟着文字。 backgroundImagePosition({ x:10, y:7}) 图片的可以自定义位置,请问一下,怎么样自定义文字的文字
Button('搜索应用').borderRadius('50%').backgroundColor(0xF2F2F2).fontColor(0xBFBFBF)
.backgroundImage($r('app.media.ProduceSearch'))
.backgroundImageSize({width:25,height:25}).backgroundImagePosition({ x:10, y:7})
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
right: { anchor: 'applicationCenter', align: HorizontalAlign.Start },
left: { anchor: 'title', align: HorizontalAlign.End }
}).margin(10).layoutWeight(1).align(Alignment.Center)
当前button里没有字体具体的位置的设置,可以通过align和padding达到想要的效果,backgroundImagePosition不占空间,可以设置align想左对齐,再设置padding的left相当于图片width+backgroundImagePosition的x+5vp即可