I've got an application that draws a custom title bar using the following style for the application theme:
<style name="App_Theme" parent="android:Theme">
<item name="android:windowTitleSize">30dip</item>
<item name="android:windowTitleBackgroundStyle">#style/App_TitleBackground</item>
</style>
This does not give me the holo theme. So I set the to parent="#android:style/Theme.Holo". This crashes the application with the following error:
E/AndroidRuntime(2048): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
Is it disallowed to use custom title bar using:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
Or am I missing something here?
PS:
The code works perfectly fine with the parent set to "Android:Theme".
I'm using API Level 14
Let your activity use a theme with following attribute:
<item name="android:windowActionBar">false</item>
mido is correct
<item name="android:windowActionBar">false</item>
is the solution when using #android:style/Theme.Holo (default for ICS).
One observation, if you use #android:style/Theme.Holo.NoActionBar change it back to the default #android:style/Theme.Holo.
Mostly for the benefit of future visitors, one cannot use Window.FEATURE_CUSTOM_TITLE with Holo themes. Setting android:windowActionBar is not what I wanted, since I wanted a title bar, although a customized one.
My workaround, was to requestWindowFeature(Window.FEATURE_NO_TITLE) and add another layout that looked like a titlebar in my activity. That way, I get the best of both worlds.
Related
I'm developing an app for Android wearables. I want to create a layout working on both round and square screens. Therefore I'm using BoxInsetLayout.
I also want to use a CheckBox from Material Theme. Therefore I'm using a custom theme derived from Theme.AppCompat.Light.
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
The problem is that BoxInsetLayout is not working properly on round screens. I'm having the same issue as described here but the solution mentioned there is not working for me. The relevant code parts are the same except the theming part.
When I switch the theme to Theme.DeviceDefault I only get the CheckBox from Holo.
Try adding:
<item name="android:windowOverscan">true</item>
to your theme. It is necessary for dispatching insets.
I have a LoginActivity where I use an AppCompat theme like this:
<activity
android:name=".LoginActivity"
android:theme="#style/Theme.AppCompat.Light.Dialog"
android:label="Login" />
I am aware that as of this post Google has not yet added Material Themes in AppCompat library for DIALOGS, so I assumed it will fall back on Holo. Instead, this is what I get:
Keep in mind, I am not using the AppCompat toolBar. In the Activity, I am not even making a reference to the ActionBar. What you see above is default behavior, yet I cannot figure out where it is coming from. Is this a bug perhaps?
(Also, the EditText fields are not being colored with the Primary color for the app.)
Note: see my final edit for possibly the best solution
For what it's worth, I do think this is a bug. However, a valid workaround that I discovered is to use #style/Base.Theme.AppCompat.Light.Dialog.FixedSize. Based on your screenshot I think this will work for you as well. However, I have not tested palette coloring yet.
From what I can tell in my testing, this extends the gray border while still allowing you to use AppCompat and v21.
Edit: one side-effect is it now appears that all dialog activities are the same size, which may not work for you. Also, I haven't figured out how to remove the title - requestWindowFeature and supportRequestWindowFeature with Window.FEATURE_NO_TITLE seems to be causing
java.lang.RuntimeException: Unable to start activity ComponentInfo{myclass}:
android.util.AndroidRuntimeException: requestFeature() must be called before adding content
even though I've tried it before and after super.onCreate and definitely before setContentView
Edit#2: Removing the title via XML theming works, and since you have no title there is no bizarre gray box to worry about, which means you can drop the FixedSize setting and the dialog will wrap it's content like it did in earlier versions.
<style name="MyActivityDialogTheme" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
Edit #3: You can also just simply remove the gray background - this may be the best solution because it does not require the Base. prefix:
<style name="MyTitledActivityDialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">false</item>
<item name="android:windowTitleBackgroundStyle">#android:color/transparent</item>
<item name="windowActionBar">false</item>
</style>
In my app I'm using the ActionBarCompat Theme.AppCompat (like holo but backwards compatable) style but I'd like to use the Theme.AppCompat.Light.DarkActionBar style for the action bar only.
So far I've tried numerous things in xml,
<item name="actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
but it doesn't change the ActionBar at all.
Any Suggestions?
Thank you
Try to use
<item name="actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
<item name="android:actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
first line for preICS platforms, second for ICS. or you can split this style between values and values-v14 folders
In my AndroidManifest file i do not declare a theme.
The result is:
black background and ABS with blue background, also states of list item's is blue.
thats fine.
now i want to make to set the indeterminateProgressStyle to Widget.ProgressBar.Small
Therefore i have to declare my own style like this:
<style name="Custom" parent="??">
<item name="android:actionBarStyle">#style/ActionBarIPS</item>
</style>
what should i enter in the parent parameter?
i want all style behaviors like before (black background with blue ABS and blue list item states etc as it is defined when i dont declare a theme attribute in AndroidManifest.
EDIT:
i also need to know this parent's value:
<style name="ActionBarIPS" parent="ABS with blue background">
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgress</item>
</style>
the version without a style in manifest:
the version with custom style and parent=Theme.Sherlock
i want the first version with indeterminate spinner set to "small"
It's depend to your current style, It can be Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.ForceOverflow and etc, e.g:
<style name="Custom" parent="Theme.Sherlock or Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/ActionBarIPS</item>
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgress</item>
</style>
Note: You must declare this style in style.xml in your values directory.
Edited:
You got blue ActionBar without using ABS because you're using Samsung TouchWiz default UI.
If you install your APK in non-samsung devices you won't see this blue action bar, But If you are forced to have blue actionbar then put the following image in your drawable directory and set it as your actionbar background through:
getSupportActionBar().setBackgroundDrawable(getResources()
.getDrawable(R.drawable.TouchWiz_ActionBar_Bg));
Try to use "Theme.Sherlock" as a parent. Also I suggest to add:
<item name="actionBarStyle">#style/ActionBarIPS</item>
How to change a style from code?
I got a style used all across my app, for all buttons. If the user changes the skin of the app, the background of this style should change.
<style name="ActionBtn">
<item name="android:layout_width">#dimen/action_btn_width</item>
<item name="android:layout_height">#dimen/action_btn_height</item>
<item name="android:background">#drawable/btn_frame_bgstate</item>
<item name="android:padding">#dimen/action_btn_padding</item>
<item name="android:layout_margin">#dimen/action_btn_margin</item>
</style>
So far the only idea I got is to make a custom button that itself chooses its background on creation.
I have not found any good, generic way for skinning android apps yet, but if I could change styles from code, that would do the trick.
All suggestions welcome!
1) Create different themes for your skins.
2) Set those themes programatically using following code in your onCreate method.
setTheme(resid);
resid is the id of your theme.