Side Menu.Android
1.0.2
在 dribble 上检查这个项目。
在 Behance 上查看该项目。
上帝保佑乌克兰!
取决于 Ozodrukh 的 2.3+ 版本的 CircularReveal 动画动画工具
首先,您必须使用git submodule update --init
命令上传动画子模块
或者您可以使用命令添加 gradle 依赖项:
dependencies {
implementation ' com.github.yalantis:Side-Menu.Android:1.0.2 '
}
。
和命令:
repositories {
maven {
url " https://jitpack.io "
}
}
dependencies {
implementation ' com.github.ozodrukh:CircularReveal:(latest-release)@aar '
}
要添加 gradle 依赖项,您需要打开 build.gradle (在您的应用程序文件夹中,而不是在项目文件夹中),然后在依赖项块中复制并添加依赖项;
对于 CircularReveal 模块
您必须创建特殊的覆盖布局以显示在当前的Circular Reveal
动画视图后面。要将所有项目添加到菜单中,您必须将它们全部添加到LinearLayout
中
< android .support.v4.widget.DrawerLayout
xmlns : android = " http://schemas.android.com/apk/res/android "
android : id = " @+id/drawer_layout "
android : layout_width = " match_parent "
android : layout_height = " match_parent " >
< io .codetail.widget.RevealFrameLayout
android : id = " @+id/conteiner_frame "
xmlns : android = " http://schemas.android.com/apk/res/android "
android : layout_width = " match_parent "
android : layout_height = " match_parent " >
< LinearLayout
android : id = " @+id/content_overlay "
android : layout_width = " match_parent "
android : layout_height = " match_parent "
android : orientation = " vertical " />
< LinearLayout
android : id = " @+id/content_frame "
android : layout_width = " match_parent "
android : layout_height = " match_parent "
android : orientation = " vertical " />
< android .support.v7.widget.Toolbar
android : id = " @+id/toolbar "
android : layout_height = " wrap_content "
android : layout_width = " match_parent "
android : minHeight = " ?attr/actionBarSize "
android : background = " ?attr/colorPrimary " />
</ io .codetail.widget.RevealFrameLayout>
< ScrollView
android : id = " @+id/scrollView "
android : scrollbarThumbVertical = " @android:color/transparent "
android : layout_width = " 80dp "
android : layout_height = " match_parent "
android : layout_gravity = " start|bottom " >
< LinearLayout
android : id = " @+id/left_drawer "
android : orientation = " vertical "
android : layout_width = " 80dp "
android : layout_height = " wrap_content "
android : divider = " @android:color/transparent "
android : dividerHeight = " 0dp "
android : background = " @android:color/transparent " >
<!-- Layout of Drawer -->
</ LinearLayout >
</ ScrollView >
</ android .support.v4.widget.DrawerLayout>
ViewAnimator viewAnimator = new ViewAnimator <>( ActionBarActivity . this ,
new ArrayList < Resourceble >(),
( LinearLayout ) findViewById ( R . id . left_drawer ),
contentFragment , drawerLayout );
//to open menu you have to override ActionBarDrawerToggle method
@ Override
public void onDrawerSlide ( View drawerView , float slideOffset ) {
super . onDrawerSlide ( drawerView , slideOffset );
if ( slideOffset > 0.6 && viewAnimator . getLinearLayout (). getChildCount () == 0 )
viewAnimator . showMenuContent ();
}
public void onDrawerClosed ( View view ) {
super . onDrawerClosed ( view );
viewAnimator . getLinearLayout (). removeAllViews ();
viewAnimator . getLinearLayout (). invalidate ();
}
所有菜单项应实现Resourceble
接口以获取菜单项名称和可绘制资源 所有片段应实现ScreenShotable
以获取片段的屏幕截图
您可以自定义放置在菜单中的图标,或添加更多项目。只需更改您解析的列表即可查看动画师。例如:
private List < SlideMenuItem > list = new ArrayList <>(); \ the list of menu items
SlideMenuItem menuItem0 = new SlideMenuItem ( ContentFragment . CLOSE , R . drawable . icn_close );
list . add ( menuItem0 );
SlideMenuItem menuItem = new SlideMenuItem ( ContentFragment . BUILDING , R . drawable . icn_1 ); f irst parameter is the id of menu item , the second is the icon resouce
list . add ( menuItem );
SlideMenuItem menuItem2 = new SlideMenuItem ( ContentFragment . BOOK , R . drawable . icn_2 );
list . add ( menuItem2 );
viewAnimator = new ViewAnimator <>( this , list , contentFragment , drawerLayout , this );
如果您向我们发送使用我们组件的项目的链接,我们将非常高兴。只需发送电子邮件至 [email protected] 如果您对动画有任何疑问或建议,请告诉我们。
PS 我们将发布更多包含在代码中的精彩内容以及关于如何使 Android (iOS) 的 UI 变得更好的教程。敬请关注!
Copyright 2019, Yalantis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.