Skip to content

Commit

Permalink
consummate
Browse files Browse the repository at this point in the history
to better
  • Loading branch information
gplcn committed Apr 21, 2016
1 parent e5440c0 commit 08e56eb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
# SlidingMenu
pattern QQ5.0
##简介
  这个工程是自己模仿QQ5.0侧滑菜单效果的实现,属于自定义的ViewGroup,主要是使用ViewDragHelper来实现ViewGroup中对子View的拖拽,并实现子View的伴随移动,需要考虑的细节较多
##使用帮助
   
1.在布局使用自定义的SlidingMenu作为容器,添加两个子view(只能是2个不能多也不能少)

<com.gpl.qqslidingmenu.view.SlidingMenu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/slideMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity" >

<include layout="@layout/layout_menu"/>
<include layout="@layout/layout_main"/>
</com.gpl.qqslidingmenu.view.SlidingMenu>

2.在Activity中填充View初始化相关控件

...

3.为slidingMenu添加监听器

slidingMenu.setOnDragStateChangeListener(new OnDragStateChangeListener() {
@Override
public void onOpen() {
menu_listview.smoothScrollToPosition(new Random().nextInt(menu_listview.getCount()));
}
@Override
public void onDrag(float fraction) {
ViewHelper.setAlpha(iv_head, 1-fraction);
}
@Override
public void onClose() {
ViewPropertyAnimator.animate(iv_head).translationX(15)
.setInterpolator(new CycleInterpolator(4)).setDuration(300).start();
}
});
##实现效果
![Alt text](https://github.com/gplcn/SlidingMenu/raw/master/Screenshots/Screenshot01.gif)
Binary file added Screenshots/Screenshot01.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gpl.qqslidingmenu;
package com.gpl.qqslidingmenu;

import java.util.Random;

Expand Down Expand Up @@ -31,9 +31,9 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
final ListView menu_listview = (ListView) findViewById(R.id.menu_listview);
ListView main_listview = (ListView) findViewById(R.id.main_listview);
SlidingMenu slideMenu = (SlidingMenu) findViewById(R.id.slideMenu);
SlidingMenu slidingMenu = (SlidingMenu) findViewById(R.id.slideMenu);
final ImageView iv_head = (ImageView) findViewById(R.id.iv_head);
slideMenu.setOnDragStateChangeListener(new OnDragStateChangeListener() {
slidingMenu.setOnDragStateChangeListener(new OnDragStateChangeListener() {

@Override
public void onOpen() {
Expand Down

0 comments on commit 08e56eb

Please sign in to comment.