繁体   English   中英

Xamarin表单:未显示浮动操作按钮

[英]Xamarin Forms: Floating action button not getting displayed

我试图在我的xamarin表单项目中显示浮动操作按钮。 我使用以下xaml文件,Button没有显示,但我不明白为什么。 请帮我解决这个问题。 我正在使用FAB.FORMS库来显示浮动操作按钮:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
        xmlns:fab="clr-namespace:FAB.Forms;assembly=FAB.Forms" 
        x:Class="iFocusDiscussionForum.PostList" Title="Discussion List" >
    <ContentPage.Content>
        <RelativeLayout>
        <ContentView
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
            <ListView x:Name="listview" RowHeight="120" ItemSelected = "OnItemSelected">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Padding="5" Margin="5">
                                </StackLayout>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            </ContentView>
            <fab:FloatingActionButton 
                Source = "plus.png" 
                Clicked = "Handle_Clicked" 
                Size="Normal"
                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-60}"
                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-60}"/>
            <!--<StackLayout HorizontalOptions="End" VerticalOptions="End" BackgroundColor="#F4F5F8">
                <fab:FloatingActionButton x:Name="testing" Image="plus.png"  Clicked="testingClicked" BackgroundColor="#F4F5F8" BorderColor="Transparent" />
            </StackLayout>-->
    </RelativeLayout>
    </ContentPage.Content>
</ContentPage>

你需要添加FloatingActionButtonRenderer.InitControl(); 进入AppDelegate.cs

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.Init();

        Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule());

        ImageCircleRenderer.Init();

        TintedImageRenderer.Init();

        FloatingActionButtonRenderer.InitControl();

        LoadApplication(new App());

        return base.FinishedLaunching(app, options);
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM