我想创建一个垂直菜单,当按下菜单按钮时,它会出现在屏幕中间。我已实现它,它出现在页面底部但不是我想要的那个...下面我的代码和我的目标图片实现
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/expandall"
android:orderInCategory="100"
android:showAsAction="always"
android:title="Expand All"/>
<item
android:id="@+id/collapseall"
android:orderInCategory="100"
android:showAsAction="withText"
android:title="Collapse All"/>
<item
android:id="@+id/myprofile"
android:orderInCategory="100"
android:showAsAction="withText"
android:title="My Profile"/>
<item
android:id="@+id/signout"
android:orderInCategory="100"
android:showAsAction="always"
android:title="Sign Out"/>
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.collapseall:
// Single menu item is selected do something
collapseAll();
return true;
case R.id.expandall:
expandAll();
return true;
}
}