嗨,我正在使用 jfeinstein10/SlidingMenu 库将幻灯片菜单实现到我的项目中。
主页.java
import android.os.Bundle;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
public class HomePage extends SlidingFragmentActivity {
SlidingMenu menu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_page);
setBehindContentView(R.layout.behind);
//customize the slide menu
menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setBehindOffsetRes(R.dimen.slidewidth);
}
}
XML 文件:
activity_home_page.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
后面.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
维度.xml
**<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name = "slidewidth">60dp</dimen>
<dimen name="shadow">15dp</dimen>
</resources>**
我的问题是,
运行应用程序时,我滑动屏幕,但屏幕完全隐藏,而不是代码设置的偏移量
menu.setBehindOffsetRes(R.dimen.slidewidth);
我做错了什么?有人可以帮忙吗?