我正在使用jfeinstein10/SlidingMenu ...
在下图中,它是错误的屏幕截图。请注意,当我滑动关闭菜单时,菜单内容显示在内容活动的顶部。
我正在使用 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" >
<com.slidingmenu.lib.SlidingMenu xmlns:sliding="http://schemas.android.com/apk/res-auto"
android:id="@+id/slidingmenulayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
sliding:viewAbove="@layout/activity_start"
sliding:viewBehind="@layout/activity_menu"
sliding:touchModeAbove="fullscreen"
sliding:behindScrollScale="@dimen/behind_scroll_scale"
sliding:behindOffset="@dimen/behind_offset"
sliding:shadowDrawable="@drawable/shadow"
sliding:shadowWidth="@dimen/shadow_width"
sliding:selectorEnabled="true"
/>
</LinearLayout>
@layout/activity_menu:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/list_menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
</FrameLayout>
Main_Activity.java:
public class MainActivity extends SherlockActivity{
private SlidingMenu menu;
private ActionBar action;
private ListView listView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MenuClass menu_data[] = populateMenuData();
MenuAdapter adapter = new MenuAdapter(this, R.layout.listview_row_item, menu_data);
listView = (ListView)findViewById(R.id.list_menu);
listView.setAdapter(adapter);
menu = (SlidingMenu) findViewById(R.id.slidingmenulayout);
menu.setFadeEnabled(true);
menu.setFadeDegree(0.35f);
action = getSupportActionBar();
action.setDisplayHomeAsUpEnabled(true);
menu.setBehindCanvasTransformer(new CanvasTransformer() {
@Override
public void transformCanvas(Canvas canvas, float percentOpen) {
float scale = (float) (percentOpen * 0.25 + 0.75);
canvas.scale(scale, scale, canvas.getWidth() / 2, canvas.getHeight() / 2);
}
});
}
谁能帮助我或告诉我我做错了什么?