我正在使用此幻灯片菜单java class https://github.com/dmitry-zaitsev/AndroidSideMenu/commits/master但我不知道如何在活动内容上绘制幻灯片菜单这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<com.agimind.widget.SlideHolder
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/smenu"
android:layout_height="match_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="140dp"
android:layout_height="match_parent"
>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/mainBg"
android:weightSum="12"
android:layout_height="match_parent">
</LinearLayout>
</com.agimind.widget.SlideHolder>
这是像这张照片的结果:
但我需要做类似这样的事情:
有没有机会这样做?
答案 0 :(得分:-1)
只需使用android.support.v4.widget.DrawerLayout:
<android.support.v4.widget.DrawerLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ListView
android:id="@+id/left_wraper"
android:layout_width="320dp"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:background="#DDFAFAFA"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
/>
</android.support.v4.widget.DrawerLayout>
第一个孩子是你的内容,第二个孩子是你的菜单持有者。 你可以像这样即时通讯:
mDrawer = (DrawerLayout) findViewById(R.id.drawer);
mDrawerList = (ListView) findViewById(R.id.left_wrapper);
String[] names = { "Create", "Show up", "Hide out", "WebView", "Registration", "LogIn View" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, names);
mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
最后是DrawerClickListener类:
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
switch (position) {
case 0: break;
case 1: break;
}
}