如何在 Zebble for Xamarin 的页面底部创建固定按钮?
How to create fixed button to the bottom of the page in Zebble for Xamarin?
我需要在带有列表视图的页面底部创建两个按钮。因此,我在页面正文中创建了两个堆栈,并将列表视图和按钮放入其中,如下所示:
<z-place inside="Body">
<Stack Direction="Vertical">
<Stack Id="top">
</Stack>
<Stack Id="bottomMenu" Direction="Horizontal">
<Button Text="Btn1" CssClass="btmButton1"></Button>
<Button Text="Btn2" CssClass="btmButton2"></Button>
</Stack>
</Stack>
</z-place>
样式表是这样的:
//Android.scss
.btmButton1 {
background: linear-gradient(to bottom, #039795, #196e6d);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
.btmButton2 {
background: linear-gradient(to bottom, #5c0eb3, #3f1968);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
#top {
height: calc("(Zebble.Device.Screen.Height - view.ActualHeight)-140");
background: #dadada
}
#bottomMenu {
width: calc("Zebble.Device.Screen.Width");
margin-top: calc("(Zebble.Device.Screen.Height - view.ActualHeight)-140");
position: fixed;
}
但是,当我设置#top 高度按钮时,它被隐藏了。
要在导航栏页面底部制作按钮栏,您可以在 common.scss 中为所有平台使用此 css 角色。
.btmButton1 {
background: linear-gradient(to bottom, #039795, #196e6d);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
.btmButton2 {
background: linear-gradient(to bottom, #5c0eb3, #3f1968);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
#top {
height: calc("(Zebble.Device.Screen.Height - 116)");
background: #dadada
}
#bottomMenu {
width: calc("Zebble.Device.Screen.Width");
height:52px;
}
而您的主页面视图代码正文是:
<z-place inside="Body">
<Stack Direction="Vertical">
<Modules.ContactsList Id="top" />
<Stack Id="bottomMenu" Direction="Horizontal">
<Button Text="Btn1" CssClass="btmButton1"></Button>
<Button Text="Btn2" CssClass="btmButton2"></Button>
</Stack>
</Stack>
</z-place>
在上面的代码中有一个注意事项是列表视图,在列表视图中,您应该使用可以上下滚动列表的滚动视图。
我需要在带有列表视图的页面底部创建两个按钮。因此,我在页面正文中创建了两个堆栈,并将列表视图和按钮放入其中,如下所示:
<z-place inside="Body">
<Stack Direction="Vertical">
<Stack Id="top">
</Stack>
<Stack Id="bottomMenu" Direction="Horizontal">
<Button Text="Btn1" CssClass="btmButton1"></Button>
<Button Text="Btn2" CssClass="btmButton2"></Button>
</Stack>
</Stack>
</z-place>
样式表是这样的:
//Android.scss
.btmButton1 {
background: linear-gradient(to bottom, #039795, #196e6d);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
.btmButton2 {
background: linear-gradient(to bottom, #5c0eb3, #3f1968);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
#top {
height: calc("(Zebble.Device.Screen.Height - view.ActualHeight)-140");
background: #dadada
}
#bottomMenu {
width: calc("Zebble.Device.Screen.Width");
margin-top: calc("(Zebble.Device.Screen.Height - view.ActualHeight)-140");
position: fixed;
}
但是,当我设置#top 高度按钮时,它被隐藏了。
要在导航栏页面底部制作按钮栏,您可以在 common.scss 中为所有平台使用此 css 角色。
.btmButton1 {
background: linear-gradient(to bottom, #039795, #196e6d);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
.btmButton2 {
background: linear-gradient(to bottom, #5c0eb3, #3f1968);
color: #ffffff;
height: 52px;
margin: 0;
border-radius: 0;
}
#top {
height: calc("(Zebble.Device.Screen.Height - 116)");
background: #dadada
}
#bottomMenu {
width: calc("Zebble.Device.Screen.Width");
height:52px;
}
而您的主页面视图代码正文是:
<z-place inside="Body">
<Stack Direction="Vertical">
<Modules.ContactsList Id="top" />
<Stack Id="bottomMenu" Direction="Horizontal">
<Button Text="Btn1" CssClass="btmButton1"></Button>
<Button Text="Btn2" CssClass="btmButton2"></Button>
</Stack>
</Stack>
</z-place>
在上面的代码中有一个注意事项是列表视图,在列表视图中,您应该使用可以上下滚动列表的滚动视图。