【发布时间】:2017-04-29 18:16:59
【问题描述】:
我在我的工具栏中使用了背景图片,由于某种原因,工具栏只适用于 mipmap 而不是 drawable。
在我的 app_bar_main.xml 文件中:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@mipmap/bar"
app:popupTheme="@style/AppTheme.PopupOverlay" />
如您所见,我使用 mipmap 而不是 drawable,但是当我使用 drawable 时应用程序崩溃并给出以下错误:
二进制 XML 文件第 11 行:二进制 XML 文件第 16 行:膨胀错误 类 android.support.v7.widget.Toolbar
必须提到这个mipmap使用只是让我的应用程序非常慢,而且它会跳帧,所以我想把它改成drawable。
如何将图像的工具栏背景资源从mipmap更改为drawable?
编辑:
样式.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="LightDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColor">@android:color/primary_text_light</item>
<item name="background">@drawable/bar</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
【问题讨论】:
-
你的
suppport library to 23.2.1是什么? -
@Ninja 我在哪里可以查看支持?我的构建 gradle 文件说:'com.android.support:support-v4:25.0.0'