Implementing Gmail Tablet like Navigation Drawer(像导航抽屉一样实现 Gmail 平板电脑)
问题描述
我正在研究 Gmail 应用程序的平板电脑设计.在那个 Navigation Drawer
实现与其他实现不同.我已附上图片供您参考.
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);
}
使用侦听器更改完整窗格和部分窗格的 alpha:
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);
}
}
更多信息:http://blog.sqisland.com/2015/01/partial-slidingpanelayout.html
这篇关于像导航抽屉一样实现 Gmail 平板电脑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:像导航抽屉一样实现 Gmail 平板电脑
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01