xamarin.forms-页面底部的滑动信息框 [英] xamarin.forms - Sliding information box in bottom of the page

查看:441
本文介绍了xamarin.forms-页面底部的滑动信息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习xamarin.forms技术。标题的意思是我要制作滑动信息框(从屏幕的底部,左侧或右侧)。一切都应该在页面/视图的底部。将xamarin.forms中的某些内容也放置在底部也很棘手。

I am learning xamarin.forms technology.What mean by title is that I want to make sliding information box (from bottom, left or right side of the screen). Everything should be in the bottom of the page/view. Also placing in bottom something in xamarin.forms is also petty tricky.

我想这样做而不是对话框,因为我不希望在弹出警报对话框时感到不舒服,并且我不想强迫用户单击任何东西

I want to do this instead of dialog, because I dont want to feeze ui when alert dialog pop and i dont want force an user to click anything

伙计们告诉我我该怎么做?

Could you guys show me how can I do that?

推荐答案

您应该为此使用AbsoluteLayout,下面举一个例子:

You should use AbsoluteLayout for this, there goes an example:

// ContentPage:

var layout = new StackLayout {
 // you page content
};

Content = new NotifyLayoutView(layout);

然后查看类:

public class NotifyLayoutView : AbsoluteLayout
{
   public NotifyLayoutView(View content)
   {
        var flash = new StackLayout
        {
            BackgroundColor = Color.Red,
            HorizontalOptions = LayoutOptions.FillAndExpand,
            Children = {
               new Label { Text = "My notification" }
            }
        };

        SetLayoutFlags(content, AbsoluteLayoutFlags.All);
        SetLayoutBounds(content, new Rectangle(0f, 0f, 1f, 1f));
        SetLayoutFlags(flash, AbsoluteLayoutFlags.WidthProportional | 
        AbsoluteLayoutFlags.PositionProportional);
        SetLayoutBounds(flash, new Rectangle(0.5, 0.99, 0.95, AutoSize));
        Children.Add(content);
        Children.Add(flash);
   }
}

要更改闪光灯的可见性,可以使用:

To change flash visibility you can use:

// open
await flash.ScaleTo(1.0f, 100);
await flash.FadeTo(1.0f, 100);

// hide
await layout.ScaleTo(0.0f);
await layout.FadeTo(0.0f);

这篇关于xamarin.forms-页面底部的滑动信息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆