我正在尝试实现自定义应用标题。我做了一个自定义布局,将标题文本颜色更改为白色。自定义应用标题
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="0dp"
android:text="@string/title_activity_main"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/textColorWhite"/>
而且在活动的onCreate()
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.activity_home);
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.my_icon);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.layout_custom_app_title);
它没有Android 2.2的设备上运行。但是,我在4.0版本上成功测试了
有没有人有任何解决方法?
编辑:
<style name="customWindowTitle">
<item name="android:textColor">@color/textColorWhite</item>
</style>
<style name="LightThemeSelector" parent="android:Theme.Light">
<item name="android:windowBackground">@drawable/app_background</item>
<item name="android:textColor">@color/textColorBlack</item>
<item name="android:windowTitleStyle">@style/customWindowTitle</item>
</style>
是。不要仅仅因为您想要不同的文本颜色而设置自定义视图。在自定义主题的帮助下更改它。 – 2013-03-20 14:19:53
是否可以使用主题更改应用标题颜色? – Renjith 2013-03-20 14:21:11