jfeinstein 10实施

时间:2013-03-17 21:52:04

标签: android slidingmenu

我尝试实现JFeinstein库来创建滑动菜单。如果我在屏幕上的任何位置仅在左边距上做滑动手势,它就可以了。如果我在那里做一个幻灯片手势将改变我的菜单视图的视图,它将把它放在我不想要的全屏幕...有人能告诉我为什么会发生这种情况?我的代码是:

MainActivity.java

package com.example.studentsnotebook;

import android.annotation.SuppressLint;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;

import com.slidingmenu.lib.SlidingMenu;
import com.slidingmenu.lib.app.SlidingActivity;

@SuppressLint("NewApi")
public class MainActivity extends SlidingActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setBehindContentView(R.layout.activity_menu);
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int menu_width = width - width/3;
        if (menu_width < 100){
            menu_width = 100;
        }
        SlidingMenu menu = new SlidingMenu(this);
        menu.setBehindOffset(menu_width);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        menu.setShadowWidth(menu_width/2);
        menu.setShadowDrawable(R.drawable.shadow);
        menu.setFadeDegree(0.35f);
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        menu.setMenu(R.layout.activity_menu);
        menu.setSlidingEnabled(true);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

0 个答案:

没有答案