【发布时间】:2014-01-06 01:02:31
【问题描述】:
我正在将我的应用程序从自定义标题栏切换到 ActionBar 支持库,因为我喜欢 ActionBar 提供的功能,而我之前避免使用它,因为它只是 3.0+。我的 ActionBar 工作正常,这很好,但我的应用程序在屏幕底部还有一个较低的栏,我希望保持与顶部的 ActionBar 相同的外观。由于看起来 ActionBar 使用图像背景(九个补丁 PNG)而不是像我以前那样定义颜色,我需要从我的布局 xml 访问操作栏底部可绘制对象的可绘制对象,并将其用作底部栏的背景。
我查看了支持 v7 库,发现像 @drawable/abc_cab_background_bottom_holo_dark 这样的可绘制对象,并且手动输入它非常适合深色主题。但是,我想添加一些东西,可以自动为 AndroidManifest 中指定的主题拉取正确的可绘制对象,无论是浅色主题还是深色主题。
下面是一些有问题的 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:background="@drawable/abc_ab_bottom_solid_light_holo">
在 AndroidManifest.xml 中:
<application android:icon="@drawable/icon"
android:allowBackup="true"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:theme="@style/Theme.AppCompat.Light" >
我发现的所有内容都在讨论如何使用您自己的主题编辑 ActionBar,但我想做相反的事情,使用基于股票 appcompat 主题的股票 ActionBar 可绘制来编辑我自己的栏。具体来说,我应该为 android:background= 设置什么来引用当前主题的版本:
<item name="actionModeSplitBackground">@drawable/abc_cab_background_bottom_holo_dark</item>
在 v7/appcompat/res/values/themes_base.xml 中定义?
【问题讨论】:
标签: android xml android-layout android-actionbar themes