实施Gmail的平板电脑像抽屉式导航 [英] Implementing Gmail Tablet like Navigation Drawer

查看:472
本文介绍了实施Gmail的平板电脑像抽屉式导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找到Gmail应用程序的平板电脑设计。在该导航抽屉的实施是与其他人不同。我附上图片,供大家参考。

I was looking into the tablet design of Gmail application. In that Navigation Drawer implementation is different from others. I have attached image for your reference.

和还当我展开了抽屉里应该发生像正常的导航抽屉的行为。

And also when I expand the the drawer it should happen like normal navigation drawer behavior.

我想以同样的方式来实现。我正在寻找,但我发现只有这链接这是不是这样的帮助。谁能给我建议,我怎么能做到这一点!

I would like to implement in the same way. I was searching but i found only this link Which is not so helpful. Can anyone give me suggestions how can I do this!

推荐答案

您可以使用 SlidingPaneLayout 上的交叉淡入淡出的主要窗格和自定义侦听保证金。

You can use a SlidingPaneLayout with a margin on the main pane and custom listener for the cross fading.

<com.sqisland.android.CrossFadeSlidingPaneLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sliding_pane_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <FrameLayout
      android:layout_width="240dp"
      android:layout_height="match_parent"
      android:background="@color/purple">
  <TextView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:text="@string/full"/>
  <TextView
      android:layout_width="64dp"
      android:layout_height="match_parent"
      android:background="@color/blue"
      android:text="@string/partial"/>
  </FrameLayout>
  <TextView
      android:layout_width="400dp"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:layout_marginLeft="64dp"
      android:background="@color/light_blue"
      android:text="@string/pane_2"/>
</com.sqisland.android.CrossFadeSlidingPaneLayout>

子类 SlidingPaneLayout 键,发现在部分或全部窗格 onFinishInflate

Subclass SlidingPaneLayout and find the partial and full panes in onFinishInflate:

protected void onFinishInflate() {
  super.onFinishInflate();

  if (getChildCount() < 1) {
    return;
  }

  View panel = getChildAt(0);
  if (!(panel instanceof ViewGroup)) {
    return;
  }

  ViewGroup viewGroup = (ViewGroup) panel;
  if (viewGroup.getChildCount() != 2) {
    return;
  }
  fullView = viewGroup.getChildAt(0);
  partialView = viewGroup.getChildAt(1);

  super.setPanelSlideListener(crossFadeListener);
}

改变全窗格和部分面板与听众的字母:

Change the alpha of the full pane and partial pane with a listener:

private SimplePanelSlideListener crossFadeListener 
    = new SimplePanelSlideListener() {
  public void onPanelSlide(View panel, float slideOffset) {
    super.onPanelSlide(panel, slideOffset);
    if (partialView == null || fullView == null) {
      return;
    }

    partialView.setVisibility(isOpen() ? View.GONE : VISIBLE);
    partialView.setAlpha(1 - slideOffset);
    fullView.setAlpha(slideOffset);
  }
};

此外,隐藏的布局被打开时,局部窗格

Also, hide the partial pane when the layout is opened.

protected void onLayout(
    boolean changed, int l, int t, int r, int b) {
  super.onLayout(changed, l, t, r, b);

  if (partialView != null) {
    partialView.setVisibility(isOpen() ? View.GONE : VISIBLE);
  }
}

更多信息:<一href="http://blog.sqisland.com/2015/01/partial-slidingpanelayout.html">http://blog.sqisland.com/2015/01/partial-slidingpanelayout.html

这篇关于实施Gmail的平板电脑像抽屉式导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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