【问题标题】:Standard ActionBar icon without default left-margin / padding没有默认左边距/填充的标准 ActionBar 图标
【发布时间】:2015-08-19 08:30:18
【问题描述】:

对于 API 级别 > 14 的 Holo 主题,我在 ActionBar 中检索带有左边距的众所周知的外观,如下所示:

<style name="AppBaseTheme" parent="@android:style/Theme.Holo">

当应用 Material-theme 并支持 AppCompat_v7(不更改代码或改用首选的新 ToolBar)时,缺少左边距。

<style name="AppBaseTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

为什么以及如何解决这个问题?

【问题讨论】:

    标签: android android-actionbar margin


    【解决方案1】:

    作为第一个解决方法,我向 res/drawable/ 添加了一个名为 icon.xmlLayer List 可绘制资源,如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item
            android:drawable="@drawable/ic_launcher"
            android:left="20dp"/>
    </layer-list>
    

    并在 AndroidManifest.xml 中将此可绘制对象作为徽标而不是原始图标本身引用:

            <activity
                android:logo="@drawable/icon" ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      • 2011-11-24
      • 2012-07-10
      • 2015-02-15
      相关资源
      最近更新 更多