菜单图标未显示在工具栏中

时间:2016-08-05 06:35:20

标签: android material-design android-toolbar android-menu

我尝试在toolbar.i中添加菜单。我写了一些代码,但我的情况非常奇怪。我在工具栏中看不到菜单图像右侧,但是当我点击它时(我的意思是工具栏右侧)菜单是展示 这是我的来源

<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="com.unipay.business.activities.MainActivity">


    <item
        android:id="@+id/transaction_all"
        android:orderInCategory="100"
        android:title="@string/history_all"
        app:showAsAction="never" />
    <item
        android:id="@+id/transaction_Income"
        android:orderInCategory="100"
        android:title="@string/history_income"
        app:showAsAction="never" />
    <item
        android:id="@+id/transaction_Outcome"
        android:orderInCategory="100"
        android:title="@string/u_history_outcome"
        app:showAsAction="never" />
    <item
        android:id="@+id/transaction_advanced_search"
        android:orderInCategory="100"
        android:title="@string/u_history_advance"
        app:showAsAction="never" />

我可以像这个菜单一样创建

enter image description here

这是我的自定义工具栏布局xml代码

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/u_common_header_height"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ToolbarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextAppearance="@style/Toolbar.TitleText">

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

    <ImageView
        android:id="@+id/u_back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="@dimen/u_sign_open_menu_margin"
        android:padding="@dimen/u_sign_open_menu_margin"
        android:src="@mipmap/ic_arrow_back_white" />


    <ImageView
        android:id="@+id/logo_header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@mipmap/logo_header"
        android:visibility="gone" />

    <TextView
        android:id="@+id/header_tittle"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginLeft="72dp"
        android:gravity="center"
        android:textColor="#ffffff"
        android:textSize="@dimen/u_common_text_size" />

</RelativeLayout>

我像这样初始化了我的工具栏

 toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

这是工具栏样式

  <style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <!-- android:textColorPrimary is the color of the title text in the Toolbar  -->
    <item name="android:textColorPrimary">@android:color/holo_blue_light</item>
    <!-- actionMenuTextColor is the color of the text of action (menu) items  -->
    <item name="actionMenuTextColor">@android:color/holo_green_light</item>
    <!-- Tints the input fields like checkboxes and text fields -->
    <item name="colorAccent">@color/colorPrimary</item>
    <!-- Applies to views in their normal state. -->
    <item name="colorControlNormal">@color/colorPrimary</item>

    <item name="colorControlActivated">@color/colorPrimary</item>

    <item name="colorControlHighlight">@color/colorPrimary</item>
</style>


<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
    <item name="android:textSize">21sp</item>
    <item name="android:textStyle">italic</item>
</style>
谁能告诉我我做错了什么?正如我说的菜单在工具栏中工作,但我看不到菜单图像 感谢

2 个答案:

答案 0 :(得分:0)

index

改为 app:showAsAction =“always”或“ifRoom”

答案 1 :(得分:0)

const cassandra = require('cassandra-driver');
const databaseConfig = require('./config/database.json');

const authProvider = new cassandra.auth.PlainTextAuthProvider(databaseConfig.cassandra.username, databaseConfig.cassandra.password);

const db = new cassandra.Client({
    contactPoints: databaseConfig.cassandra.contactPoints,
    authProvider: authProvider
});

db.execute("INSERT INTO my_keyspace.my_table (id, year, value, country) VALUES (now(), 2010, 100.000, 'TUNISIE');", function(err, result){
    if (err){
        console.log(err);
    }
    else {
       console.log("azeaea") 
    }
});