nativescript - 如何从 XML 向 Button 添加新行
问题描述
在我的 NativeScript 项目中,我正在尝试制作一个带有图标的底部栏,然后在其下方添加与其相似的单词。像这样
这是我尝试做的html:
<GridLayout rows="*,60">
<ScrollView row="0">
<WrapLayout orientation="horizontal">
<Label text="There are no leagues currently." style="color: black; text-align: center; font-weight: bold"></Label>
<Label text="Contact your commissioner" style="color: black; text-align: center; font-weight: bold"></Label>
<Label text="to create one." style="color: black; text-align: center; font-weight: bold"></Label>
</WrapLayout>
</ScrollView>
<StackLayout row="1" orientation="horizontal">
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="Home"></Span>
</FormattedString>
</Button>
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="All Cocktails"></Span>
</FormattedString>
</Button>
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="Favorite"></Span>
</FormattedString>
</Button>
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="Profile"></Span>
</FormattedString>
</Button>
</StackLayout>
</GridLayout>
这是我的CSS:
.fa {
font-family: 'Font Awesome 5 Free';
}
但是,每当我尝试这样做时,它都会像这样
我不太确定去哪里,所以任何帮助都会很棒。谢谢!
这是我的代码的一个工作示例:https ://play.nativescript.org/?template=play-ng&id=r8Jodt&v=19
解决方案
为 BottomBar 使用 GridLayout,您可以在此处查找操场示例
<GridLayout columns="*,*,*,*" rows="*,*" width="100%" row="1" backgroundColor="lightgray">
<Label text="" row="0" col="0" class="fa" width="100%" textAlignment="center"></Label>
<Label text="Home" row="1" col="0" width="100%" textAlignment="center"></Label>
<Label text="" row="0" col="1" class="fa" width="100%" textAlignment="center"></Label>
<Label text="All Cocktails" row="1" col="1" width="100%" textAlignment="center"></Label>
<Label text="" row="0" col="2" class="fa" width="100%" textAlignment="center"></Label>
<Label text="Favorite" row="1" col="2" width="100%" textAlignment="center"></Label>
<Label text="" row="0" col="3" class="fa" width="100%" textAlignment="center"></Label>
<Label text="Profile" row="1" col="3" width="100%" textAlignment="center"></Label>
</GridLayout>
推荐阅读
- python - 托管私有 Pip 存储库
- python - 单击相应的QGraphicsPixmapItem时如何打开图像?
- javascript - Tensorflow.js tf.browser.fromPixels() 必须是 HTMLVideoElement
- javascript - 网页抓取时如何获取 HTML 代码而不是源代码?
- reactjs - react如何在不同组件中使用axios实例?
- javascript - 如何将字符串数组转换为嵌套的 JSON 对象?
- mysql - 来自 django ORM 的单个对象值
- asp.net-mvc - 状态服务器日志事件 ID 1078 状态服务器已关闭过期的 TCP/IP 连接
- r - 保留一个圆形划分的新列
- javascript - React 应用程序、http-proxy-middleware 和 axios 代理到后端服务器(生产和开发)