2
votes

I want to display some of my app activities as white "popups" when the device screen is big enough. So I am styling these activities with Theme.Holo.Light.DialogWhenLarge:

<style name="PopupActivity" parent="@android:style/Theme.Holo.Light.DialogWhenLarge"></style>

But this way I get light (white) action bars (when activity is not rendered as dialog), because of the Holo Light theme. I know there's the Theme.Holo.Light.DarkActionBar theme to get white contents and dark bar, but I can't use it because of Theme.Holo.Light.DialogWhenLarge, obviously. So I tried to change my style to:

<style name="PopupActivity" parent="@android:style/Theme.Holo.Light.DialogWhenLarge">
    <item name="android:actionBarStyle">@android:style/Widget.Holo.ActionBar</item>
</style>

But with no results. How can I have a Theme.Holo.Light.DialogWhenLarge themed activity, but with a dark action bar?

3
When the device is big enough means what? 7 inch tablet+ you mean?Nitin Sethi

3 Answers

1
votes

it looks like you just need to make a copy of DialogWhenLarge

in values/themes:

<style name="PopupActivity" parent="@android:style/Theme.Holo.Light.DarkActionBar">
</style>

in values-large/themes:

<style name="PopupActivity"
        parent="@android:style/Theme.Holo.Light.DialogWhenLarge">
</style>

note you could also use Theme.Holo.Light.Dialog.MinWidth as the parent for your large version but if things were added to the DialogWhenLarge theme you would miss out on those.

that should work but I dont have anything setup to test it.

1
votes

The question is now really really old but I think I've got a cleaner way to handle this :

<style name="fullScreenDialogTheme" parent="Base.Theme.AppCompat.Light.DialogWhenLarge">
    <item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
0
votes

I realize this is an old question, but I ran into the same problem when adding tablet support for an existing app. I also tried to use the DialogWhenLarge theme and customize the actionBar for some activities. The app was built using version 19 of the support libraries. Upgrading to version 22 made the custom styling work.

I'm using Android Studio, and the build.gradle file was changed from

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:appcompat-v7:19.1.0'
}

to

dependencies {
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
}

This also caused other changes such as adding a back arrow for navigation to the action bar, and also button text became allCaps, but that's another matter.