Android 工具栏是空的&;不活跃

Android 工具栏是空的&;不活跃,android,material-design,android-appcompat,Android,Material Design,Android Appcompat,使用此代码 布局: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" > <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match

使用此代码

布局:

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentTop="true" >

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    />

  </RelativeLayout>
输出只是一个蓝色的空矩形,它不会对触摸事件做出反应,就像一张图片。我也可以通过按下菜单按钮(它正在工作)得到菜单,但右上角没有三个点,什么也没有

我错过了什么或错了什么


谢谢

如果您想在按下主页按钮时转到上一个活动,则必须覆盖活动上的“OnOptions ItemSelected(MenuItem item)”方法。例如:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        return true;
    }
    if (id == android.R.id.home) {
        onBackPressed();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
对于设置按钮(这三个点),您必须创建如下菜单(文件):

<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">

    <item
         android:id="@+id/action_settings"
         android:orderInCategory="100"
         android:title="@string/action_settings"
         app:showAsAction="never" />
</menu>

我希望这些示例能够帮助您。

谢谢,但这不是我想要的,我解决了我的问题,这是因为我有一个启动屏幕&代码没有在刷新视图中执行
<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">

    <item
         android:id="@+id/action_settings"
         android:orderInCategory="100"
         android:title="@string/action_settings"
         app:showAsAction="never" />
</menu>
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}