1

我想在我的android应用程序的底部创建导航栏。我正在使用NativeScript来创建应用程序。有没有插件可以做到这一点?Android应用程序的底部导航栏(NativeScript)

<page 
xmlns="http://schemas.nativescript.org/tns.xsd" 
xmlns:drawer="nativescript-telerik-ui/sidedrawer" 
xmlns:widgets="shared/widgets" 
xmlns:statusbar="nativescript-statusbar" 
xmlns:bottomnav="nativescript-bottomnavigation" 
loaded="pageLoaded"> 
<statusbar:StatusBar ios:barStyle="light" /> 
<page.actionBar> 
<action-bar title="NativeScript"> 
    <navigation-button icon="res://ic_menu" tap="toggleDrawer" ios:visibility="collapsed" /> 
    <action-bar.actionItems> 
    <ios> 
     <action-item icon="res://ic_menu" ios.position="left" tap="toggleDrawer" /> 
    </ios> 
    </action-bar.actionItems> 
    <ActionItem tap="onDelete" ios.systemIcon="16" ios.position="right" text="Delete" android.position="popup"/> 
    <ActionItem id="logoutButton" tap="logOut" ios.systemIcon="16" ios.position="right" text="LogOut" android.position="popup"/> 
</action-bar></page.actionBar> 
<drawer:rad-side-drawer id="drawer"> 
<drawer:rad-side-drawer.mainContent> 
    <!-- Home page contents --> 
    <StackLayout loaded="contentLoaded"> 
    <image src="https://i.imgur.com/LY3cb3A.png" id="logo" tap="fun" height="100" margin="20 0 0 0" /> 
    <label text="Welcome to the NativeScript drawer template! This is the home page. Try tapping the logo." margin="20" horizontalAlignment="center" textWrap="true" /> 
    </StackLayout> 
    </drawer:rad-side-drawer.mainContent> 
<drawer:rad-side-drawer.drawerContent> 
    <widgets:drawer-content /> 
</drawer:rad-side-drawer.drawerContent> 
</drawer:rad-side-drawer> 

+0

几个解决方案:http://forum.nativescript.org/t/android-tabview-to-look-like-ios/215 –

+0

我我还会补充一点,我开始移植下面提到的本地库之一:https://github.com/bradmartin/nativescript-bottomnavigation - 我从来没有时间完成,但有人开始了我所做的和发布的内容一个插件。我认为这是回购:https://github.com/kobby-sun/nativescript-bottomnavigation已经有一段时间了,因为我已经看过它。 –

+0

我克隆存储库,并试图运行它,但它给出了一个错误。 错误:从XML构建UI。 @file:///app/main-page.xml:7.4 >模块未找到元素nativescript-bottomnavigation:BottonNavigation – Mill3r

回答

2

我做了什么是创造最好的方法研究底部avigation。

对于我来说,最简单的方法是创建一个GridLayout两行:一个用于滚动内容,一个用于底部导航:

<GridLayout rows=*,60"> 
    <ScrollView row="0"> 
     ... scrolling content ... 
    </ScrollView> 
    <StackLayout row="1"> 
     ... navigation buttons ... 
    </StackLayout> 
</GridLayout> 

第二行表示导航。在我的示例中,我使用的高度为60 dp。第一行(滚动内容)占用垂直空间的其余部分。星号(*)表示 - 占用尽可能多的空间。

您可以检查我的下面的文章中体验:这里NativeScript: how to create a fixed bottom navigation