【问题标题】:ActionBar option icon not showing properlyActionBar 选项图标未正确显示
【发布时间】:2017-07-12 13:44:46
【问题描述】:

在我的 ActionBar 中,我只有一个选项菜单项,它只有图标,没有文字。

上下文菜单图标和徽标对齐良好(垂直居中),但素材电视图标 (24d - 96x96) 看起来已折叠。我无法弄清楚如何使其与上下文菜单图标的高度完全相同。这是我的 AppBarLayout 文件的一部分:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay">

        <ImageView
            android:id="@+id/imgToolbarLogo"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:src="@drawable/dunya_logo_white" />


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

</android.support.design.widget.AppBarLayout>

菜单项是:

    <item
    android:id="@+id/action_watch_live"
    android:icon="@drawable/ic_tv_white"
    android:title=""
    android:orderInCategory="1"
    app:showAsAction="always"/>

请帮助我如何居中对齐此材质图标,如左侧的上下文菜单图标。

【问题讨论】:

标签: android android-actionbar


【解决方案1】:

我认为您的 Image Drawable 文件夹不正确,请尝试在正确的 Drawable 文件夹中插入正确的图像尺寸。您可以参考以下链接

http://iconhandbook.co.uk/reference/chart/android/

What is the recommended ActionBar icon size in Material Design (Android API 21+)?

【讨论】:

  • 你是对的,我没有使用 Android Studio 的 Add Image Asset 工具添加图标,该工具根据标准操作栏菜单图标调整图像大小。我使用“添加图像资源”向导添加了图像,我的问题已经解决,它会自动将图标放在相应的文件夹中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-23
  • 1970-01-01
相关资源
最近更新 更多