Android的棒棒糖,从标题工具栏添加弹出式菜单 [英] Android Lollipop, add popup menu from title in toolbar
本文介绍了Android的棒棒糖,从标题工具栏添加弹出式菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看不到如何增加从标题的弹出式菜单来完成像显示在众多的材料设计实例。任何帮助将是非常美联社preciated。
I'm unable to see how adding a popup menu from the title is accomplished like is shown in many of the material design examples. Any help would be much appreciated.
推荐答案
你会需要一个微调添加到工具栏:
You're going to need to add a Spinner to the Toolbar:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:background="?attr/colorPrimary">
<Spinner
android:id="@+id/spinner_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
您一定要去禁用默认的标题:
You will then need to disable the default title:
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
然后,您可以根据需要在你的活动获取和设置微调/片段。
You can then retrieve and setup the Spinner as needed in your Activity/Fragment.
这篇关于Android的棒棒糖,从标题工具栏添加弹出式菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文