如何使三个点出现在Android工具栏中 [英] How to make the three dots appear in the Android toolbar
问题描述
我是Android应用程序开发的新手,我试图在UI中开发应用程序,我添加了一个工具栏,但是在不知道为什么工具栏右侧的三个点对我来说是必要的,因为我想要在其中添加注销按钮.
I am new in Android applications development, and I am trying to develop an application in UI I added a toolbar but In don't know why the three dots in the right side of the toolbar, it is necessary for me because I want to add a logout button there.
这是工具栏布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="#000">
</android.support.v7.widget.Toolbar>
这是我在活动类中添加工具栏的地方:
And here is where i add the toolbar inside the activity class:
toolbar= (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
toolbar.setTitle(R.string.app_name);
toolbar.setTitleTextColor(getResources().getColor(R.color.com_facebook_button_background_color_focused));
这是我的menu.xml:
and this is my menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".HomeActivity">
<item android:id="@+id/action_settings"
android:title="Settings"
android:orderInCategory="100"
app:showAsAction="always"
android:icon="@drawable/icon"
/>
<item
android:id="@+id/action_search"
android:title="Search">
</item>
</menu>
奇怪的是,在android studio预览中显示了三个点:
And what is weird is that in the android studio preview the three dots are shown:
我做错了什么?
推荐答案
三个点被隐藏了,因为它们是黑色的,并且工具栏背景是黑色的,所以我不得不添加这个白色主题
The three dots were hidden because they were black, and the toolbar background is black, so I had to add this white theme
android:theme="@style/ThemeOverlay.AppCompat.Dark"
进入我的工具栏布局.
这篇关于如何使三个点出现在Android工具栏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!