I am getting android.util.AndroidRuntimeException
when i am setting the theme using setTheme
method. here is my code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isCustomScreen = getIntent().getBooleanExtra("isCustomScreen", false);
if (isCustomScreen ) {
setTheme(R.style.CustomTitleTheme);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
}
setContentView(R.layout.sample_layout);
if (isCustomScreen ) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_bar);
}
}
Declaration of activity in Manifest file:
<activity
android:name=".activities.MenuActivity"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
I am getting following exception while running this code with isCustomScreen
as true:
02-17 18:35:54.619: E/AndroidRuntime(5787): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
02-17 18:35:54.619: E/AndroidRuntime(5787): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:183)
02-17 18:35:54.619: E/AndroidRuntime(5787): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2074)
02-17 18:35:54.619: E/AndroidRuntime(5787): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2225)
02-17 18:35:54.619: E/AndroidRuntime(5787): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:194)
02-17 18:35:54.619: E/AndroidRuntime(5787): at android.app.Activity.setContentView(Activity.java:1647)
02-17 18:35:54.619: E/AndroidRuntime(5787): at com.sample.activities.MenuActivity.onCreate(MenuActivity.java:39)
02-17 18:35:54.619: E/AndroidRuntime(5787): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-17 18:35:54.619: E/AndroidRuntime(5787): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-17 18:35:54.619: E/AndroidRuntime(5787): ... 11 more
I have tried removing the theme declaration from the manifest file and setting the theme in onCreate
method:
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
but on doing this i am not getting the activity with Translucent background when isCustomScreen
as false
Please suggest what should i do.
Update: added details of custom theme:
<style name="CustomWindowTitleBackground">
<item name="android:background">#000000</item>
</style>
<style name="CustomTitleTheme" parent="Theme">
<item name="android:windowTitleSize">45dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>