How to change menu theme in Android - android

My android application uses the following style:
<style name="AppTheme"
parent="android:style/Theme.Holo" ></style>
It is assigned for the whole application in the AndroidManifest.xml file :
<application
android:theme="#style/AppTheme"
[...]
Using this style, menus look like this :
However, if I use the light theme instead :
<style name="AppTheme"
parent="android:style/Theme.Light" ></style>
Menus will look like this :
My question is :
How can I apply the HOLO theme for the whole application and use only the LIGHT theme for menus ??
I just want to apply the dialog "style" of the LIGHT theme and apply the HOLO theme for everything else.

I believe you are looking for this:
<application
android:theme="#style/theme.holo.light>

Try to use "android:itemBackground" to change the background color of the menus

You can make your own white style. Put this into style.xml and give theme in AndroidManifest file this theme
<style name="MyGow.Default.NoActionBar" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">#color/silver</item>
<item name="android:actionModeBackground">#color/white</item>
</style>

Related

Android : Theme.Holo VS Theme.AppCompat

I use "#android:style/Theme.Holo" as my game's theme :
But to be able to set up a snackbar widget, I have no choice but using "#style/Theme.AppCompat", otherwise I get this error message :
You need to use a Theme.AppCompat theme (or descendant) with the design library
The problem is that the "#style/Theme.AppCompat" is visually quite different :
What could I do to stay with the same visual as "#android:style/Theme.Holo", but in the same time be able to use a snackbar widget?
EDIT
With the Yoann Hercouet's solution, here is the result :
What is missing?
I finally found the solution :
AndroidManifest.xml :
<application
android:theme="#style/Theme.AppCompat"
...
MyDialog.java :
new AlertDialog.Builder(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Dialog));
Instead of :
new AlertDialog.Builder(context);
Try updating your app theme by changing the default style for dialogs:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="alertDialogTheme">#android:style/Theme.Holo.Dialog</item>
</style>
EDIT:
Not sure why it doesn't change anything, it worked on my app, maybe try this other way and create a custom style:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="alertDialogTheme">#style/myAlertDialogStyle</item>
</style>
<style name="myAlertDialogStyle" parent="android:style/Theme.Holo.Dialog">
...
</style>

Difference between style.xml and theme.xml android studio?

Hey I'm trying to change the background of my action bar but I'm not quiet sure I understand the structure of the style files. So basically I have style.xml which is to pass on some elements a desired style. Then I've Theme.xml which is to have a group of styles in it, correct ? How do you link the two in other words how do I tell the theme I want the specified style in it ? I can't manage to change the background of the action bar so here is my code:
style.xml:
<!-- Base application theme. -->
<style name="MyActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:colorBackground">#color/color_lightBlue</item>
</style>
</resources>
theme.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyCustomTheme" parent="Theme.AppCompat.Light">
</style>
</resources>
and wtf is v11/style ?
Whether you put the attributes in styles.xml or theme.xml, they have the same effect finally if you apply the theme to your app or activity. In your AndroidManifest.xml, in order to let the theme have the effect you want, you should apply your customized theme like following to your app.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >

How to customize the Theme for whole Application

I used Theme.Sherlock.Light.DarkActionBar for my whole Application. Now the Action bar background color is black by default. How to change this color. Basically how to customize the Theme for whole Application?
<activity
android:name="com.mypath.myapp.FirstActivity"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock.Light.DarkActionBar"
>
You can use android:theme=theme_style in your <application> tag. Now if you want your action bar to be different than that given by the theme, then you can override it by defining the style between <style></style for your action bar specifically.
Here's the concept. Go to res > values > styles.xml. You can extend or customize your themes as follows:
<style name="AppBaseTheme" parent="android:Theme.Light">
<item name="android:background">#color/background_dark</item>
</style>
Update:
OR if you want to make generic (not theme specific) changes for all your applications, then you can edit sdk/platforms/android-target/data/res/values/styles.xml
OR if you want to override default themes for all your applications, then you can edit sdk/platforms/android-target/data/res/values/themes.xml
Update - found this:
ActionBar developer docs. This link says "You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11)." So I assume your target is API 11 at minimum.
If you are targeting API 11 and above, you can do advanced custom styling as follows:
<resources>
<style name="CustomActivityTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_background</item>
<item name="android:backgroundStacked">#drawable/ab_background</item>
<item name="android:backgroundSplit">#drawable/ab_split_background</item>
</style>
</resources>
Here you go , Styling Action Bar background
You can define the theme for your whole application in your manifest file in application tag as below:
<application
android:name="com.test"
android:icon="#drawable/appicon"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" > <---Define your own style here.
Have a look at http://actionbarsherlock.com/theming.html . You must create a own Theme-style.
for modifying default android sdk themes You can find android Sdk themes.xml file in :
\android-sdk\platforms\...\data\res\values\themes.Xml
so you can change your whole application theme.

set background Image to whole application in android

I want to set background image to my application in android. So my application already has a theme set in my manifest file like this
<application android:theme="#android:style/Theme.NoTitleBar" />
Now this was implemented from the themes of android package.
Now i want to add a background image to my entire application how can i do it.
<style name="Theme.NoTitleBar.BackgroundImage">
<item name="android:background">#drawable/bitzer_background</item>
</style>
I want the Theme.NoTitleBar as well.
I have changed the style below, by doing this I am overriding the Theme.NoTitlteBar
<style name="Background" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#android:color/black</item>
<item name="android:windowNoTitle">true</item>
</style>
Now my manifest file looks like this:
<application android:theme="#style/Background"/>
You have to use styles to achieve this
Check out this link
Create a theme with your background and use that theme.

How to set text color in android app for all text?

I want to define a default text color for my android app.
I have a base activity class, that all activities are extended from it and I thought this might be a good place to define the colors.
If not what is a better solution? Maybe styles?
Trouble is this, all is new to me, so feel free to advise me and provide code snippets and explanations as well.
This is what my base class looks like. As you can see it's pretty empty
package com.ccslocal.mobile.quiz.jls;
import android.app.Activity;
import android.os.Bundle;
public class BaseActivity extends Activity {
//set up app preferences here
}
As was mentioned in denis.solonenko's answer, the correct approach would be to modify your theme.
Where you define your theme (in your themes.xml or styles.xml file), you'll want to add something like this:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
...
<item name="android:textColor">#FF00FF</item>
...
</style>
Then make sure that the theme is applied to your Activity or Application in the manifest:
<application
...
android:theme="#style/AppTheme"
....
>
You can also define:
textColor - The default text color of any given view
textColorPrimary - The default text color for enabled buttons and Large Textviews
textColorSecondary - The default text color for Medium and Small Textviews
textColorTertiary - ?
(Source TextColor vs TextColorPrimary vs TextColorSecondary)
Keep in mind that many other things may override these predefined colors, such as applied styles or definitions in different resource folders.
See here for a full list of theme items: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
Create a custom theme for your app. Take look at the official guide.
Yes you are right you can make that using style. Or you can use TextView.getTextColors().getDefaultColor() for set default text color. Actually I never used this but I think it may be help you.
For style
<style name="TextColor">
<item name="android:textColor">#00FF00</item>
</style>
Then in layout file
<TextView style="#style/TextColor" />
Set your default color in your res/values/colors.xml like this
<color name="defaultTextColor">#ffffff</color>
So this color to all your texts
android:textColor="#color/defaultTextColor"
or
textView.setTextColor(R.color.defaultTextColor);
Create style for TextView:
<style name="TextViewTheme">
<item name="android:textColor">#android:color/white</item>
</style>
Apply it in style for App:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textViewStyle">#style/TextViewTheme</item>
</style>
And remember to change style in AndroidManifest.xml:
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
...
</application>
#android:color/white
yes you can change default color of react native app only add this line in styles.xml file of android src

Categories

Resources