android - 添加 fragment 时 FlyOut 菜单设计问题

标签 android android-fragments layout xamarin fragment

我试图在添加 fragment 时让我的弹出菜单正常工作。 所以,由于这段代码,我有一个弹出菜单可以工作:

https://github.com/garuma/FlyOutMenu/tree/master/FlyOutMenu

    <com.myApp.FlyOutContainer xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:id="@+id/FlyOutContainer">
         <include
              layout="@layout/menu_layout"
              android:id="@+id/menu_layout" />
         <include
              layout="@layout/content_layout"
              android:id="@+id/content_layout" />
    </comm.myApp.FlyOutContainer>

在我的应用程序开始时,content_layout 由以下布局组成:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <include
        layout="@layout/top_bar_layout"
        android:id="@+id/top_bar_layout" />
    <include
        layout="@layout/root_layout"
        android:id="@+id/root_layout" />
</LinearLayout>

启动后,我的 Activity 在 root_layout 中添加一个 fragment :

    // Create new fragment and transaction
    Fragment questionListFragment = new QuestionListFragment();
    FragmentTransaction transaction = FragmentManager.BeginTransaction();

    transaction.Add(Resource.Id.root_layout, questionListFragment);
    // Commit the transaction
    transaction.Commit();

这个新 fragment 包含滑动刷新布局和 ListView 。 当我从左向右滑动时,菜单显示良好。但要隐藏它(从右向左滑动),背景菜单。

更新:

我认为问题出在 notifyDataSetChanged 上。当菜单打开时,我的 View 不居中,我更新了我的 ListView 。所以在更新时,我的 View 被重新创建并重新居中,菜单留在后台...... 我该如何解决?

这里是截图来理解: (我还不能在 stackOverflow 上发布图片,而且不超过 2 个链接...)

问题是:

enter image description here

最佳答案

我建议使用标准导航绘制。你可以在这里找到我的例子:https://github.com/jamesmontemagno/Xam.NavDrawer

关于android - 添加 fragment 时 FlyOut 菜单设计问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29880787/

相关文章:

android - Windows Azure 移动服务能否提供对 native 移动设备功能的访问?

android - "Buttery""pre-butter"Android 中的 fragment 动画

html - 将侧边栏(放置在内容之后)向左对齐

android - 我如何知道要选择哪些目标架构?

java - Android,从字符串中获取资源ID?

java - 从 Android 中的 Assets 文件夹读取文件时遇到问题

在 fragment 动画期间,Android 新 fragment 出现在旧 fragment 下方

java - FAB 单击时根据当前显示的 fragment 启动新 Activity

css - Div 在添加元素时移动一个 div

javascript - 将元素置于最高字符和最低字符之间