标准的ActionBar图标没有默认的左边距填充。

问题描述 投票:1回答:1

随着 Holo主题 for API level > 14 我检索到的好知道的样子,在图标的左侧边距 ActionBar 如下:

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

enter image description here

应用时 材料主题AppCompat_v7 支持(不改变代码或使用首选的新的 ToolBar 取而代之的是)左边的空白不见了。

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

enter image description here

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

android android-actionbar margin
1个回答
0
投票

作为第一个变通方法,我添加了一个 层列表 可绘制资源名为 图标.xml可重绘 像这样。

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

并将这个可绘制的图标引用为logo,而不是原来的图标本身 AndroidManifest.xml:

        <activity
            android:logo="@drawable/icon" ...
© www.soinside.com 2019 - 2024. All rights reserved.