you need to use a theme.appcompat - android

I'm not a developer. I have a problem while editing a google search widget. Google app crashes with this log: https://del.dog/bihagetole
What should i do to fix that?

You must define the theme parent in your styles.xml file
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. This one does not have a action bar for example -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>

Related

Removing the default toolbar in an activity android

Before upgrading to android 3.1.I usually just change the theme to a theme. app compact. NoTitleBar but the new version of android studio is having errors recognizing it.I solved this problem by adding base to the beginning. But I can seem to find any answer regarding a style theme that supports removing the custom bar.
In your res/values/styles.xml you have this similar block of code.
Ensure that you use Theme.AppCompat.Light.NoActionBar as parent of your theme
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Add this style in style file . where other styles are mentioned .
<!-- Base application theme. -->
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimaryDark</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorPrimaryDark</item>
<item name="android:statusBarColor">#color/lightgreycolor</item>
</style>
In my case, i had to change parent theme in res/values/themes.xml

Failed to find style ... in current theme

I've faced a questionable error during my work with android studio.
Everytime I start studio and create a new project there is another render error
Failed to load AppCompat ActionBar with unknown error.
I do not clearly understand what does it mean, but it is easy to deal with it via replacing
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
but evertime I add new element to the layout, there is error
Failed to find style ... in current theme
I have found a solution, that helped almost everybody except me. But changing theme now doesn't solve the problem.
If anybody know how to deal with it please help.
You can copy the style name floatingactionbuttonstyle and included it in your apptheme.
Add this line
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
And finally theme look like this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
</style>
Just add the style name when error occured in layout editor & add the responding styles.
Here some other few elements am added in styles for others.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="chipStyle">#style/Base.Widget.MaterialComponents.Chip</item>
<item name="chipGroupStyle">#style/Widget.MaterialComponents.ChipGroup</item>
<item name="bottomNavigationStyle">#style/Widget.Design.BottomNavigationView</item>
<item name="coordinatorLayoutStyle">#style/Widget.Support.CoordinatorLayout</item>
<item name="bottomAppBarStyle">#style/Widget.MaterialComponents.BottomAppBar</item>
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
</style>
You can add default style with style name. Then you resolve this error.
In your app gradle under dependencies use this:
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
if you heven't already.

When trying to use the material theme on Android, my title bar is not using the primary colour

From my research, it appears that when using the material theme on Android the title bar should take on the primary color but for me, it stays black. I know the theme itself is working as things did change to black when I first applied the default(dark) theme. I have this set in the styles.xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
</resources>
The colors referenced from colors.xml are working as they show up on the s the de in android studio.
I have tried looking for a way to manually change the title bar but I have only found ways to do it programatically and not through layout files. I have attached a pic of what the title bar currently looks like and what i would like it to look like below:
Current title bar
What I want it to look like
Change it to
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>

PreferenceFragmentCompat setting the theme

Beginner coder here.
I am using PreferenceFragmentCompat to make a preference fragment that I can use with getSupportFragmentManager().
https://plus.google.com/+AndroidDevelopers/posts/9kZ3SsXdT2T
I am following the directions there, except I'm not sure how to set the preferenceTheme. My app crashes when I click on the settings menu with this exception is thrown
IllegalStateException: Must specify preferenceTheme in theme.
Where do I set the theme?
In values/styles.xml you have to add:
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
use this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay</item>
</style>

Textview background color got changed after adding custom theme to android app

My app interface originally looked like this. "my name" is a TextView and "my button" is a button which has an image as the background. Minimum sdk is 16.
I changed the action bar color of the app by adding a custom theme. I used the code below.
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyTheme</item>
<!-- Customize your theme here. -->
</style>
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/com_facebook_blue</item>
</style>
Then my output came like this.
All the background color got changed to the new color of the app. I only need to change the color of the action bar.
Can anyone help me?
Try this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>

Categories

Resources