Gmail的类似抽屉式导航(母版页)在xamarin.forms
和它呈现基于OS的默认行为,它呈现完美的我想要的东西,但在Android的主页面从导航栏下面开始。我想母版页覆盖屏幕的全高就像IOS这样做,有什么办法或者其解决方案,而自定义渲染还是有必要写这个Gmail的类似抽屉式导航(母版页)在xamarin.forms
使用FormsAppCompatActivity代替FormsApplicationActivity。
定义自己的toolbar.axml
toolbar.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways">
</android.support.v7.widget.Toolbar>
设定自己的ToolbarResource
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
ToolbarResource = Resource.Layout.toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
对于从FormsApplicationActivity派生的活动而不是FormsAppCompatActivity,我可以使用相同的抽屉吗? – Shyam
这是困难的,因为你必须编写自定义项目级代码来创建FormsApplicationActivity类似抽屉,这是非常复杂的特别是用于导航的抽屉里。 –
是的,你可以自定义呈现。检查这些链接。他们都使用MasterDetail页面来创建一个导航抽屉。只有“详细信息”页面变为主页面视图,主页面变为滑动菜单。这其实很简单。还有其他一些很好的例子。不过,我认为你可以通过我列出的3个链接完成工作。如果不尝试像Xamarin Forms中创建导航抽屉一样的搜索。
http://www.meritsolutions.com/mobile-development/implementing-navigation-drawer-in-xamarinforms/
https://www.syntaxismyui.com/xamarin-forms-masterdetail-page-navigation-recipe/
为雄ID你可以把主题=“@android:风格/ Theme.Black.NoTitleBar.Fullscreen”)在你的这种情况下,导航栏活动 – Slepz
将是不可见的,但我想导航栏是可见的,以及 –
你说你想充分屏幕 – Slepz