我无法使自定义标题文本或自定义标题样式正常工作。我一定做错了什么,但我不知道是什么(如果这两个问题相关)
1)关于样式(似乎被忽略了)我已经在valyes/styles.xml
<style name="MicWindowTitleBackground">
<item name="android:background">@android:color/black</item>
<item name="android:padding">0px</item>
</style>
<style name="MicWindowTitleTextAppearance">
<item name="android:textSize">20dip</item>
<item name="android:textStyle">bold|italic</item>
</style>
<style name="MicWindowTitle">
<item name="android:textAppearance">@style/MicWindowTitleTextAppearance</item>
</style>
<style name="MicTheme" parent="AppTheme">
<item name="android:windowTitleSize">44dip</item>
<item name="android:windowTitleBackgroundStyle">@style/MicWindowTitleBackground</item>
<item name="android:windowTitleStyle">@style/MicWindowTitle</item>
</style>
这在AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/replace__logo__app_android"
android:label="@string/MicAppName"
android:theme="@style/MicTheme"
android:name="com.example.example.MicApp"
>
2) 或者,我想我可以使用FEATURE_CUSTOM_TITLE,这会带来额外的好处,我可以更改标题栏中显示的标题。但是,此代码错误并带有错误消息,我*无法将 FEATURE_CUSTOM_TITLE 与其他标题功能结合*(据我所知...)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String customTitleStr = getIntent().getExtras().getString("Title");
Boolean customTitleSupported = this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
if ( (customTitleSupported) && (customTitleStr != null) ) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.override_titlebar);
final TextView myTitleText = (TextView) findViewById(R.id.myTitleText);
if ( myTitleText != null ) {
myTitleText.setText(customTitleStr);
}
}