R.Java not generated after actionbar style changes - android

I am working on designing the actionbar. I was trying to change the color of the main actionbar. I had written a style in style.xml. Untill then my project is working fine. After I declared my style in xml file R.Java committed suicide.
The following is the xml code I had written. I had tried all the solutions given in this site. None of them worked for me.
<resources>
<style name="MyCustomTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:background">F757575</item>
</style>
</resources>
Someone help me
Thank you :)

Your color is not declared properly.
Change
<item name="android:background">F757575</item>
to
<item name="android:background">#FF757575</item>

Related

How to change style of PreferenceThemeOverlay / PreferenceFragmentCompat

I worked myself thru the AndroidFundamtentals Tutorial 09.2 (App Settings) but I couldn't find a working solution for my problem.
I want to change the style (backgroundcolor) of the Settings-Fragment in my app.
That's what I have coded in the styles.xml so far:
<style name="AppThemeWithActionBar" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">#color/cr_blue_dark2</item>
<item name="colorPrimaryDark">#color/cr_blue_dark</item>
<item name="colorAccent">#color/cr_green</item>
<!-- more styles-->
<item name="preferenceTheme">#style/AppTheme.SettingsScreen</item>
</style>
<style name="AppTheme.SettingsScreen" parent="PreferenceThemeOverlay">
<item name="backgroundColor">#color/cr_black</item>
<item name="background">#color/cr_black</item> <!--one of these should make the background black-->
</style>
This code does not change the background color of the Settings fragment.
If you need more code just write an comment. :)
I just found the solution / mistake.
The parent of the style AppThemeWithActionBar is wrong.
It changes the background to light.
Change the title of the style like this:
<style name="AppThemeWithActionBar" parent="Theme.MaterialComponents">
Also change the theme of the activity in the Manifest.xml file.

Android Style Split does not work, explanation needed

i am trying to change the style of the action bar in android.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="GoetheTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/GoetheActionBar</item>
</style>
<style name="GoetheActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/base_color_dark</item>
</style>
So yeah, thats what I got. Now I have put the application theme in the android manifest to the created one (GoetheTheme). But the ActionBar does not change. If I set it to #GoetheActionBar, it does. Why does GoetheTheme style don't take the GoetheActionBar style?
Can please someone explain me the style system? I really dont get it.
Thanks in advance
Sorry, my very bad. I found out, I have to use a different parameter as parent ^^
I took a Light theme based one not android specific.
Correct:
<style name="GoetheActionBar"parent="#android:style/Theme.WithActionBar">
<item name="colorPrimary">#color/base_color_dark</item>
</style>
<style name="GoetheTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/GoetheActionBar</item>
</style>

Can't understand how to style Android app for pre-Lollipop devices using Theme.AppCompat

My brain is about to blow on Android's themes and styles. Somebody, help me, please!
I'm trying to create a theme for my app to provide as similar look for pre- and post-Lollipop devices as possible. So, I've inherited my theme from Theme.AppCompat.NoActionBar and my activities from AppCompatActivity ans set up colorPrimary, colorPrimaryDark and colorAccent. All that went well. The problems started when I tried to style background and text color. I've set android:textColorPrimary and android:textColorSecondary and got what I wanted on Lollipop device, but not on KitKat, so I've added textColorPrimary and textColorSecondary attributes to theme and after that Android Studio said that it can't build the app because these attributes can't be found. Same happened when I've tried to add colorBackground. I've tried to google it but wasn't able to found something useful about what attributes are provided by which theme and what should I use in my situation.
You must have to create two values folder one for lollipop values-v21 and simple values for pre-lollipop
See this style for pre-lollipop devices just paste it to values/styles.xml
Styles.xml
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.TransparentActivity">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/textColorPrimary</item>
<item name="android:windowBackground">#color/windowBackground</item>
</style>
</resources>
see official documentation on android blog
If you want to style the app for different apis, you have to make a folder name values-v(sdk version) for e.g values-v21 for lollipop, values-v19 for kitkat,... but in this case I think you only need to create values-v21.
inside that folder, create an xml file style.xml and based on the api to use the appropriate attributes.

Remove divider under the ActionBar

I want to remove the divider under the ActionBar, already search here for it and tried the different things, but nothing worked for me.
Here are the styles, I hope you can help me.
<style name="ListeningThemeTranslucentActionBar" parent="#style/ListeningTheme">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">#style/ListeningTranslucentActionBar</item>
<item name="android:actionBarDivider">#null</item>
</style>
<style name="ListeningTranslucentActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
You probably didn't apply your styles in the Manifest. You will have to add
android:theme="#style/ListeningThemeTranslucentActionBar"
in your Manifest.xml. (If there is already a android:theme parameter just change it to your theme.)
Also this link might be helpfull.

Android custom theme

Hello I'm making a custom theme for my app. I want to have a custom ActionBar and background for the rest of the app (below the ActionBar). I'm wondering how to do the background. Right now I have:
<style name="MyTheme" parent="android:Theme.Holo">
<item name="android:actionBarStyle">#style/dActionBar</item>
</style>
<style name="dActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#4C721D</item>
<item name="android:textColor">#FFFFFF</item>
</style>
Would I just have to do <item name-"android:background"></item> in MyTheme or would I have to create another style? After I create this do I need to put it in the res/styles folder? Also what are the API restrictions on this, if any?
Don't forget to apply your theme to your application in your AndroidManifest.xml.
<application android:theme="#style/CustomActivityTheme" ... />
You can find all the information about styling the Actionbar here.
To style your ActionBar with a nice Holo-look, try this website
Hope this helps!
Try to use below code in your Style.xml file
<resources>
<style name="Theme.Sample" parent="Theme.AppCompat">
<item name="android:colorBackground">#color/primary_material_dark</item>
<item name="actionBarTheme">#color/colorGray</item>
</style>
</resources>
Just need to use android:colorBackground as a name of item to define the background color like as below:
<item name="android:colorBackground">#color/primary_material_dark</item>
Hope you get your answer,Thanks.

Categories

Resources