我想,我想在我的应用程序与此类似我怎样才能让一个菜单视图
菜单按钮底部创建菜单的底部是在底部布局,当你点击它,它可能会扩大到项目列表。我怎样才能达到这个菜单效果?我已经在Android的抬头行动起来吧,可悲的是这只是放置在顶部。我如何定制它以达到我的目的?
一个xml草图将高度赞赏!
我想,我想在我的应用程序与此类似我怎样才能让一个菜单视图
菜单按钮底部创建菜单的底部是在底部布局,当你点击它,它可能会扩大到项目列表。我怎样才能达到这个菜单效果?我已经在Android的抬头行动起来吧,可悲的是这只是放置在顶部。我如何定制它以达到我的目的?
一个xml草图将高度赞赏!
如果你想在页面底部的自定义视图,请尝试使用RelativeLayout
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Your Contents" />
<LinearLayout
android:id="@+id/my_bottom_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/transparent_white"
android:gravity="center" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/x" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="5.6 miles" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/overflow" />
</LinearLayout>
</RelativeLayout>
为了处理溢出菜单中你可以使用PopupMenu
这样的:
PopupMenu popupMenu = new PopupMenu(context, view);
popupMenu.inflate(R.menu.my_menu);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {...});
popupMenu.show();
您可以分割你的动作条,看看它在底部:
在您的清单:
<activity
android:name=".MainActivity"
android:uiOptions="splitActionBarWhenNarrow">
<intent-filter>
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</intent-filter>
</activity>
然后,操作栏将在底部显示。
更多的信息在这里:Action Bar - Using split action bar
感谢。这正是我想要的! – Daniel