Android 在工具栏中添加三个点

Android 在工具栏中添加三个点,android,android-activity,navigation-drawer,android-toolbar,android-menu,Android,Android Activity,Navigation Drawer,Android Toolbar,Android Menu,我曾经做过一个导航抽屉,并在我的活动中展示。然后我在基本布局中添加了一个工具栏。在这些步骤之后,我试图在我的活动中显示三个点。(我对基本布局及其类进行了所有更改) 然后我发现我的活动没有变化。我想我应该用另一种方法在基本活动中添加三个点。我该怎么做 app\u base\u layout.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns

我曾经做过一个导航抽屉,并在我的活动中展示。然后我在基本布局中添加了一个
工具栏。在这些步骤之后,我试图在我的活动中显示三个点。(我对基本布局及其类进行了所有更改)

然后我发现我的活动没有变化。我想我应该用另一种方法在基本活动中添加三个点。我该怎么做

app\u base\u layout.xml

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:layoutDirection="rtl"
    tools:openDrawer="right">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textColor="@android:color/white"
                android:textSize="20sp"/>

        </android.support.v7.widget.Toolbar>

        <FrameLayout
            android:id="@+id/view_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="?attr/actionBarSize"/>

    </FrameLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="@dimen/nav_header_width"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        app:headerLayout="@layout/drawer_header"
        app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>


(有小改动)。

您可以从Google material icons下载
垂直更多
图标,提取并添加到
资源/可绘制的
文件夹:

之后,在
菜单
文件夹中创建您的
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">
<item
    android:id="@+id/moreVertical"
    android:icon="@drawable/baseline_vertical_24dp" <!--or whatever you called it -->
    android:title="@string/more"
    app:showAsAction="ifRoom" />
工具栏
与其
id
连接,然后使用:

setSupportActionBar(toolbar);

右键单击res文件夹并创建一个新的资源目录,其类型为菜单。右键单击菜单目录并创建新的资源文件。从那里,您可以从XML设计中拖放菜单项。这应该给你3个点


我所需要的就是
setSupportActionBar(工具栏)。如何更改“更多选项”?(三点菜单提示文本)
setSupportActionBar(toolbar);