【问题标题】:Xamarin Shell Right to left FlowDirection not workingXamarin Shell 从右到左 FlowDirection 不起作用
【发布时间】:2019-12-21 01:02:53
【问题描述】:

我正在使用 Xamarin 4.0 开发一个新的跨平台应用程序,我想将布局更改为从右到左的方向。

我想在屏幕右侧显示外壳项目和弹出菜单。我在 Shell 标记中尝试了此代码。但它没有用。

FlowDirection = "RightToLeft"

我该怎么办?

谢谢。

【问题讨论】:

    标签: xamarin.forms xamarin.shell


    【解决方案1】:

    可惜,应该是Shell Flyout的极限了。

    FlowDirection:只能修改子视图内容的方向,不能修改其父布局。

    在官方样例Xamarin.Forms - Xaminals中测试后,设置FlowDirection = "RightToLeft"不能改变Flyout从屏幕左侧到屏幕右侧。

    注意:如果有其他解决父布局方向的方案,会在这里更新。

    【讨论】:

      【解决方案2】:

      在 OnCreate 方法内的主要活动中:让它看起来像那样

          protected override void OnCreate(Bundle savedInstanceState)
          {
              TabLayoutResource = Resource.Layout.Tabbar;
              ToolbarResource = Resource.Layout.Toolbar;
              base.OnCreate(savedInstanceState);
              Xamarin.Essentials.Platform.Init(this, savedInstanceState);
              global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
      
              Window.DecorView.LayoutDirection = LayoutDirection.Rtl;
      
              LoadApplication(new App());
          }
      

      【讨论】:

        猜你喜欢
        • 2018-10-18
        • 1970-01-01
        • 2016-05-02
        • 2013-01-05
        • 1970-01-01
        • 2018-05-08
        • 1970-01-01
        • 1970-01-01
        • 2013-05-10
        相关资源
        最近更新 更多