【发布时间】:2014-04-07 23:25:59
【问题描述】:
背景
我正在为我的应用程序“App Manager”添加“Holo”和“Holo Light”(也许还有深色操作栏)的主题选择器。现在我首先通过 XML 文件尝试它们。
问题
我正在使用 Google 的支持库并尝试主题,但无论我使用什么属性和主题,我的 listView 上的 textViews 的颜色都有错误的颜色。
listView 包含 2 个这样定义的 TextView:
<TextView
android:id="@+id/appLabelTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/isSystemAppImageView"
android:layout_toRightOf="@+id/appIconImageView"
android:ellipsize="marquee"
android:text="label"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/appDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/appLabelTextView"
android:layout_below="@+id/appLabelTextView"
android:layout_toLeftOf="@+id/isSystemAppImageView"
android:ellipsize="marquee"
android:text="description"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText" />
Theme.AppCompat.Light 和Theme.AppCompat:
当我以编程方式完成所有操作以及使用 ActionBarSherlock 库时,也会发生同样的情况。
这是我使用的主题配置(这次尝试了 ActionBarSherlock,但普通支持库也是如此):
<style name="BaseTheme" parent="@style/Theme.Sherlock.Light"></style>
<style name="AppTheme" parent="@style/BaseTheme">
<item name="android:listSeparatorTextViewStyle">@style/PreferenceListHeader</item>
<item name="android:windowBackground">@color/normal_window_background</item>
</style>
和清单:
<application
android:name="com.lb.app_manager.utils.App"
android:allowBackup="true"
android:description="@string/app_description"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
我在这里展示的活动没有任何代码或 XML 将主题设置为与上面写的不同。
我尝试过的
我已尝试检查示例,并没有发现 XML 和代码之间存在明显差异。他们工作得很好......
此外,出于某种原因,偏好活动显示得很好。
ActionBarShelock 库也存在同样的问题。
问题
怎么可能?应该怎么做才能解决它?
【问题讨论】:
-
你试过没有
android:textAppearance属性吗? -
@shoerat 是的。我真的不知道它为什么会发生。我已经搜索了我能想到的任何东西:隐藏样式,以编程方式设置颜色,......真的不知道为什么会发生这种情况。目前,我已经为每个 textView 设置了颜色以处理这种奇怪的情况。还选择使用卡片-UI:play.google.com/store/apps/details?id=com.lb.app_manager
-
好的。我刚刚检查了
TextViews 以上,对 Galaxy Nexus(库存 Android 4.3)的Theme.AppCompat.Light和 here is the screenshot 进行了零修改。那里没有问题,对吧?我想问题出在特定的设备/模拟器上。您正在测试哪种设备/模拟器? -
@shoerat 正如我已经提到的,当我使用示例代码(甚至是“hello world”项目)时,它运行良好。我已经在具有 4.3 和 4.4 android 版本的模拟器以及我的设备(带有 4.3 的 Galaxy S3 I9300)上测试了我的应用程序。 :(
-
嗯.. 在 Play 商店中检查了您的应用,我可以看到您使用的是 ABS 主题。您可能会混合 AppCompat 和 Sherlock 样式吗?
标签: android android-listview actionbarsherlock android-theme android-support-library