找到你要的答案

Q:Hamburger icon both side with back arrow animation in toolbar for Two NavigationView android …?

Q:汉堡图标两侧背部箭头动画工具栏中两navigationview Android…?

First see the below screenshot and focus on the hamburger icon only so that you will get quick idea what I really want .?

First of all I have successfully implemented the NavigationView(Drawer) to the both side left and right So that user can open the two drawer from left & right both.

Now My question is I want hamburger icon with animation to both side. I have implemented hamburger icon to the left side of toolbar which is easy and which comes by default. but now I want it to right side also with arrow animation.

  1. Click on left hamburger icon open left drawer. (done)
  2. click on right hamburger icon open drawer from right side. (it's remaining)

So Is it possible to have two hamburger icon on a single toolbar?

Note: Both drawer are opening with gestures. and I don't have issue with it.

首先看到下面的截图和重点汉堡图标,只有这样你会得到快速的想法,我真正想要的

First of all I have successfully implemented the NavigationView(Drawer) to the both side left and right So that user can open the two drawer from left & right both.

Now My question is I want hamburger icon with animation to both side. I have implemented hamburger icon to the left side of toolbar which is easy and which comes by default. but now I want it to right side also with arrow animation.

  1. Click on left hamburger icon open left drawer. (done)
  2. click on right hamburger icon open drawer from right side. (it's remaining)

那么,是否有可能在一个工具栏上有两个汉堡图标?

注:抽屉两侧均设有手势。我没有问题。

answer1: 回答1:

I believe SlidingMenu library is what you looking for. It has LEFT and RIGHT modes.

我相信SlidingMenu图书馆是你在寻找什么。它有左右模式。

answer2: 回答2:

You can write animation which translates your right icon like this

While opening drawer from x to x-someDelta

and while closing drawer from x-somedelta to x

EDIT:

You may use ObjectAnimator and its super class Value Animator

you can do something like this

ObjectAnimator anim = ObjectAnimator.ofFloat(rightIcon, "translationX", 0,50); 

anim.start();

Use a boolean value and toggle it with 50,0 in the object animator to slide back

Also you can use setDuration method to set how long the animation should take to complete

你可以写动画翻译你的图标像这样

而从X到x-somedelta打开抽屉

and while closing drawer from x-somedelta to x

编辑:

你可以使用objectanimator和其超类价值动画

你可以做这样的事

ObjectAnimator anim = ObjectAnimator.ofFloat(rightIcon, "translationX", 0,50); 

anim.start();

使用对象的动画一个布尔值和切换与50,0滑

你也可以使用setDuration方法设置动画要多长时间完成

answer3: 回答3:

I think you can do it using FrameLayout.

Now Consider the following layout

<FrameLayout>
     <Toolbar />
     <Toolbar layout_direction="right" />
</FrameLayout>

Using this the both toolbar will appear on top of each other. Put drawer icon to both toolbar and the second toolbar will render it right side because we have specified layout direction to right.

Note : Make the upper toolbar transparent.

I hope it help you.

我认为您能做它用FrameLayout。

现在考虑下面的布局

<FrameLayout>
     <Toolbar />
     <Toolbar layout_direction="right" />
</FrameLayout>

Using this the both toolbar will appear on top of each other. Put drawer icon to both toolbar and the second toolbar will render it right side because we have specified layout direction to right.

注意:使上工具栏透明。

希望对你有帮助。

android  navigation-drawer  android-toolbar  android-design-library  navigationview