我对NativeScript很陌生。我选择它与React Native相比,因为我想100%地访问本机API。我开始与本地插件玩耍,阅读一些教程这样一个native libraries 现在我试图遵循同样的原则有了这个插件FloatingActionButton来自github.com/Clans/FloatingActionButton的NativeScript FloatingActionButton
var app = require("application");
var platformModule = require("platform");
var fs = require("file-system");
var imageSource = require("image-source");
function creatingFab(args) {
var fabMenu = new com.github.clans.fab.FloatingActionMenu(app.android.foregroundActivity);
var fabButton = new com.github.clans.fab.FloatingActionButton(args.object.android);
fabButton.setButtonSize(FloatingActionButton.SIZE_MINI);
fabButton.setLabelText("Hello Button");
//fabButton.setImageResource(imageSource.fromResource("logo"));
fabMenu.addMenuButton(fabButton);
fabMenu.hideMenuButton(false);
}
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo" class="page">
<Page.actionBar>
<ActionBar title="My App" icon="" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout class="p-20">
<Label text="Tap the button" class="h1 text-center"/>
<Button text="TAP" tap="{{ onTap }}" class="btn btn-primary btn-active"/>
<Label text="{{ message }}" class="h2 text-center" textWrap="true"/>
</StackLayout>
<android>
<placeholder id="fab" tap="fabClick" class="fab-button" margin="15" creatingView="creatingFab"/>
</android>
</Page>
预先感谢您的帮助
很酷的东西 - 如果你想使用的东西使用了android已经写原生FAB小部件有这个插件https://github.com/bradmartin/nativescript-floatingactionbutton,但我了解你正在采取的学习方法。这是我在一年前写这篇文章时开始的地方:)所以继续做你正在做的事情,你会越来越欣赏本地文字。 @MarekMaszay下面的答案可能会有所帮助。如果没有,你正在使用的Android库可能会要求你传递一个图像,它看起来像你注释了设置图像的行。 –
@BradMartin,我是你博客的粉丝。感谢像你这样的人,这只是我第二天的本地文字,但我学到了很多东西。我一定会使用你的插件github.com/bradmartin/nativescript-floatingactionbutton。我已经看过它了。我只是想看看我是否可以轻松地连接到任何本机插件。我非常惊讶于NativeScript可以做些什么。我只需要把它推到极限,看看我能走多远:)。 – Selom
我已取消注释该行并遵循@MarekMaszay的建议,但仍无法使用。我会继续研究它。 – Selom