I am looking for a way to slightly modify the default window title in an Android app for both phone and tablet. The example below is a tablet view of the title bar as standard:
I have tried implementing a custom title bar, which works but the context menu (circled in red) disappears, which I need. All I want to do is change the color of the bottom border or remove the bottom border altogether.
Is there a way to make changes whilst keeping the context menu?
Thanks
In your manifest in application tag define as :
android:theme="#style/mytheme"
Now in res/values you can define a file say theme.xml with content as :
<resources>
<style name="mytheme" parent="#android:style/Theme" >
<item name="android:_DEFAULT_BASE_COLOR_1">#XXXXXX</item>
<item name="android:windowNoTitle">true</item>
... .
</style>
</resources>
This will change the basic colour scheme of your application. Here are the color themes primarily used on Android: http://developer.android.com/design/style/color.html
Related
I am trying to customize background and color of Title bar. I have seen many example on android site and stack overflow but nothing worked out for me.
In examples they are adding new elements in title bar but i want to customize existing title bar.
I do not want to change anything else. I only want to change background color and font color of text.
If you are using Android Lollipop (api 21+), you can edit the "styles21.xml" (in the res directory) code and add the following:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme using Material Design here. -->
<!-- Title Bar color here -->
<item name="android:colorPrimary">#YOUR_COLOR_HERE</item>
<!-- Background color here -->
<item name="android:windowBackground">#YOUR_COLOR_HERE</item>
</style>
</resources>
For more information see Google's "Using the Material Theme" here.
This XML code will work throughout the whole app (each different view) unless otherwise specified.
I hope this is what you are looking for!
Surfing the web I've found this site which generates Android custom themes. I've used it to create my personal theme: it inherits from Android:Widget.Holo (should be the dark one with white text) and some fancy widget witha a custom color.
Because the theme inherits from Android:Widget.Holo, I have dark background and white text; but in some activity i need the opposite: white background with dark text.
When it comes to change the text color of most item i can do it easily using android:textColor="#android:color/black", but when i try to use it on spinner item it does nothing.
I've tried to create a new style only for spinner items, but i canno't apply it...
This is the first style generated (white text on black background):
<style name="SpinnerAppTheme" parent="android:Widget.Holo.Spinner">
<item name="android:background">#drawable/apptheme_spinner_background_holo_dark</item>
<item name="android:dropDownSelector">#drawable/apptheme_list_selector_holo_dark</item>
</style>
And this is the second I've generated (the opposite, back text on white background):
<style name="SpinnerDarkTextAppTheme" parent="android:Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/apptheme_spinner_background_holo_light</item>
<item name="android:dropDownSelector">#drawable/apptheme_list_selector_holo_light</item>
<item name="android:textColor">#android:color/black</item>
</style>
But when I use style="#style/SpinnerDarkTextAppTheme nothing happens.
How can I do to have 2 different styles (obviously working at the same time) for my spinners?
SOLVED using this piece of code.
You can create two themes in the XML and switch between them before you set the content view:
https://stackoverflow.com/a/6390025/2219600
Another approach:
https://stackoverflow.com/a/16101936/2219600
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>
I was changing the background of the Actionbar in my App and to make text readable again I have to change the color of the text. I was successful with title/subtitle and the tab-texts, but I am struggling with the text of the action-items - they stay white no matter what I tried . Anyone has a hint on how to do that?
Also the overflow-icon is white which does not look too good on the wooden background - is that an extremely good reason to use the stuff below? I am not really sure what's the reason to not do it, but as I do not have a big device-test-park I better want to be sure ;-)
<!-- the following can be used to style the overflow menu button
only do this if you have an *extremely* good reason to!! -->
<!--<style name="MyOverflowButton" parent="Widget.Sherlock.ActionButton.Overflow">
<item name="android:src">#drawable/ic_menu_view</item>
<item name="android:background">#drawable/action_button_background</item>
</style>-->
I also struggled with this, but the solution to changing action item text color was:
<style name="My.Theme" parent="Theme.Sherlock.Light">
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
The key here was to use this attribute in the general theme, not in the actionbar style.
Try starting with android:theme="#style/Theme.Sherlock.Light" in your Manifest and then changing your styles. The light theme features dark action items. Or just look through the light theme to find out how to change them.
I'm trying to make a custom titlebar for my first Android application.
While I can find lots on the web about how to make them so you can change colours etc, I want my titlebar to look the same as the "standard" titlebar, but with a button that I can configure. This means copying the device's currently active themes to be able to style it in exactly the same way.
Not all devices simply use a gradient in the titlebar style, so adding a gradient (as suggested in other SO questions) doesn't really make sense.
Does anyone have any pointers how to read the style information?
try to extend an existing theme e.g.
create your own style which can ofcourse extend from existing from an existing theme. change the windowNoTitle to true.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="noTitleBarStyle" parent="android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/darkGrey</item>
<item name="android:colorForeground">#ff3333</item>
</style></resources>
or try to do it runtime as discussed here
Android - change custom title view at run time
I hope this helps.