两个菜单Android应用 [英] Two menu Android app

查看:146
本文介绍了两个菜单Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的公司拥有iOS应用程序,有两个滑动菜单:一份是用于导航的左侧,一个在显示应用广泛的上下文信息和行动的权利。 iOS的应用程序有一个像小部件的动作条与主内容窗格中显示通过菜单(这意味着它是隐藏的),当滑动。由于公布的指南使用导航抽屉里,我们看更新的Andr​​oid版本的用户界面,以符合(尽可能)。考虑到这一点,我的UI设计已经要求一对夫妇的工作演示,可以摆在用户面前得到反馈。她问了三个样本:

The company I work for has an iOS application that has two sliding menus: one on the left that is used for navigation, and one on the right that displays app wide contextual info and actions. The iOS application has an ActionBar like widget that slides with the main content pane when displaying either of the menus (meaning it is hidden). Due to the published guidelines for using a navigation drawer, we are looking at updating the UI in the Android version to conform (as closely as possible). With that in mind, my UI designer has asked for a couple of working demos that can be put in front of users to get feedback. She's asked for three samples:

  1. 一个具有横跨顶部的固定操作栏。两个菜单将覆盖主内容窗格中,但不行动起来吧。这将按照公布的指导方针。

  1. one that has a stationary action bar across the top. Both menus would overlay the main content pane but not the action bar. This would follow the published guidelines.

一个功能类似于目前的Facebook应用程序。在动作条(或同等学历)被认为是主要内容窗格中的一部分,将覆盖/滑开或者抽屉被打开时。

one that functions like the current Facebook app. The ActionBar (or equivalent) is considered part of the main content pane and would be covered/slide away when either drawer is opened.

一个是的previous两个混合:在左侧导航菜单应该在操作栏(​​以下准则)滑出。正确的抽屉就滑出了操作栏。这种情况是类似目前的Evernote应用

one that is a hybrid of the previous two: the left navigation menu should slide out under the action bar (following the guidelines). The right drawer would slide out over the action bar. This scenario is similar to the current Evernote app.

到目前为止,我一直在摆弄 SlidingMenu 并有功能演示的#1和# 2。根据我读过这里 ,我应该是能够完成#1使用Android官方抽屉式导航。不过,我一直无法得到任何工作演示#3。它看起来并不像DrawerLayout,可向工作在动作条的顶部,这样它出来。

So far, I've been tinkering with SlidingMenu and have a functional demo for #1 and #2. Based on what I've read here, I should be able to accomplish #1 using the official Android navigation drawer. However, I haven't been able to get anything working for demo #3. It doesn't look like DrawerLayout can be made to work over top of the ActionBar so it's out.

是否有可能使用两个抽屉(使用SlidingMenu):一个与动作条的工作和一个不?如果没有,是否有任何其他解决方案在那里,将工作或做我需要看看滚动我自己的解决方案?

Is it possible to use two drawers (using SlidingMenu): one that works with the ActionBar and one that doesn't? If not, are there any alternative solutions out there that will work or do I need to look at rolling my own solution?

推荐答案

所以,事实证明这是可能使用SlidingMenu。从本质上讲,我结束了创建两个SliderMenu对象:

So it turns out this is possible using SlidingMenu. Essentially I ended up creating two SliderMenu objects:

public class SlidingMenuEvernoteActivity extends SlidingFragmentActivity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.sliding_menu_main);
    setBehindContentView(R.layout.sliding_menu_red);
    setSlidingActionBarEnabled(false);

    SlidingMenu leftMenu = getSlidingMenu();
    leftMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    leftMenu.setMode(SlidingMenu.LEFT);
    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.sliding_menu_main, new ListFragment())
            .commit();

    SlidingMenu rightMenu = new SlidingMenu(this);
    rightMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    rightMenu.setMode(SlidingMenu.RIGHT);
    rightMenu.setMenu(R.layout.sliding_menu_blue);
    rightMenu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.sliding_menu_blue, new ListFragment())
            .commit();
  }
}

请注意:由于活动延伸SlidingFragmentActivity,就没有必要创建两个SlidingMenu手动对象。首先是在回调中自动创建。

Note: because the activity extends SlidingFragmentActivity, there is no need to create two SlidingMenu objects manually. The first is automatically created in a callback.

和这里的相关布局文件:

And here are the relevant layout files:

* sliding_menu_main.xml *     

*sliding_menu_main.xml*

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:clickable="true"
    android:id="@+id/sliding_menu_main">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:id="@+id/textView"
        android:layout_gravity="center" />
</FrameLayout>

* sliding_menu_red.xml *     

*sliding_menu_red.xml*

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sliding_menu_red"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ff001c">

</LinearLayout>

* sliding_menu_blue.xml *     

*sliding_menu_blue.xml*

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sliding_menu_blue"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0028ff">

</LinearLayout>

这篇关于两个菜单Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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