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