i have a little problem
for my activities, i created 2 differents styles, i had no problem with it but suddenly it couldn't build anymore,
i had 4 errors
"No resource found that matches the given name: attr 'textColor'"
"No resource found that matches the given name: attr 'textSize'"
"No resource found that matches the given name: attr 'textColor'"
"No resource found that matches the given name: attr 'textSize'"
on the /app/build/intermediates/res/merged/debug/values/values.xml.
and i have no idea how to fix it
The message you have shared seems there is a problem in the debug.
So you can simply perform CLEAN_PROJECT from the BUILD OPTION and then REBUILD_PROJECT.
If that still fails, try restarting the Android Studio.
ok, here is what i added in the styles :
<style name="title">
<item name="android:layout_margin">20dp</item>
<item name="android:gravity">center</item>
<item name="android:textSize">30sp</item>
<item name="android:textColor">#color/colorAccent</item>
<item name="android:textStyle">bold</item>
</style>
<style name="text">
<item name="android:layout_marginTop">30dp</item>
<item name="android:gravity">center</item>
<item name="textSize">15sp</item>
<item name="textColor">#color/colorPrimary</item>
<!-- <item name="android:textStyle"></item> -->
</style>
which has been added into the values file, in the intermediates res.
and the error is precisely in this file.
Related
Please understand that I started to use this program with almost no prior knowledge of java let alone designing an app.
So thing is that after updating to the version, it seems that the plugins(?) for the themes.xml dont work anymore. The error messages tell me that resouces are missing and honestly I dont know what this means or how to fix it.
Down below are the codes and a picture.
Thank you
<!-- Base application theme. -->
<style name="Theme.listest" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/purple_500</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
The error message and the code
The problem is here:
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
You have not the color "colorPrimaryVariant"
you can add it or replace it with another one, for example:
<item name="android:statusBarColor" tools:targetApi="l">#color/purple_700</item>
I do not want the night mode in my application, I tried to delete a file themes.xml (night), But that didn't work, I also tried moving the themes.xml file content to a themes.xml (night) And it didn't work either.
themes.xml file
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Can you help me thanks!.
Please use default app theme in style file instead of "Theme.AppCompat.DayNight.NoActionBar".
Night mode will not work unless we use the Day Night theme in style. There for you can use default theme for your application to disable the dark mode.
<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>
try add this
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">
then this in layout
android:forceDarkAllowed="false"
I'm trying to style a ListPreference Dialog to suit a dark theme, with the accent color given by my code. However, the text color for each option does not seem to change no matter what attribute I add to it. Is there a way to do this without having to create my own Dialog class?
P.s. I have tried the solution given in this answer: ListPreference text color
And no, it does not seem to work.
Here's the required code from styles.xml: (Not the entire code but it's all I need to show)
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="dialogPreferenceStyle">#style/DialogBoxTheme</item>
<item name="listDividerAlertDialog">#style/DialogBoxTheme</item>
<item name="alertDialogStyle">#style/DialogBoxTheme</item>
<item name="alertDialogTheme">#style/DialogBoxTheme</item>
</style>
<style name="DialogBoxTheme" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:layout_gravity">center</item>
<item name="android:layout_width">320dp</item>
<item name="android:layout_height">200dp</item>
<item name="android:layout_marginStart">16dp</item>
<item name="android:layout_marginEnd">16dp</item>
<item name="android:textColorPrimary">#color/colorPrimary</item>
<item name="android:textColorSecondary">#color/colorPrimary</item>
<item name="android:textColorHint">#color/Silver</item>
<item name="android:textColorTertiary">#color/colorAccent</item>
<item name="android:textColor">#color/colorPrimary</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:background">#color/cpWhite</item>
<item name="textColorAlertDialogListItem">#color/colorPrimary</item>
<item name="android:textColorAlertDialogListItem">#color/colorPrimary</item>
</style>
(note that I've set colorPrimary and colorAccent to vary with the theme)
Here's the output that it gives:
ListPreference Dialog appearance
Answering my own question:
I forgot to add the attribute
<item name="android:alertDialogTheme">#style/DialogBoxTheme</item>
to the AppTheme in styles.xml.
I'll describe my problem first. I'm trying an android app. Doing it using Xamarin Android. I've done the parts I need, the necessary code; but Compiling my code gives me some errors in the Styles.xml file.
The error is like this::
Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget'. (APT0000) (TestALLApp)
Basically 5 errors, the above error repeating itself 5 times for the 5 style definitions in the Stylex xml file.
This is my Styles.xml file::
<resources>
<style name="Widget.SampleContentContainer"> <---- error shown here
<item name="android:paddingTop">#dimen/vertical_page_margin</item>
<item name="android:paddingBottom">#dimen/vertical_page_margin</item>
<item name="android:paddingLeft">#dimen/horizontal_page_margin</item>
<item name="android:paddingRight">#dimen/horizontal_page_margin</item>
</style>
<style name="Widget.SampleDashboard.Grid" parent="Widget">
<item name="android:stretchMode">columnWidth</item>
<item name="android:columnWidth">200dp</item>
<item name="android:numColumns">auto_fit</item>
<item name="android:drawSelectorOnTop">true</item>
<item name="android:horizontalSpacing">#dimen/margin_medium</item>
<item name="android:verticalSpacing">#dimen/margin_medium</item>
</style>
<style name="Widget.SampleDashboard.Item" parent="Widget">
<item name="android:background">#drawable/sample_dashboard_item_background</item>
<item name="android:paddingTop">#dimen/margin_small</item>
<item name="android:paddingLeft">#dimen/margin_medium</item>
<item name="android:paddingRight">#dimen/margin_medium</item>
<item name="android:paddingBottom">#dimen/margin_medium</item>
</style>
<style name="Widget.SampleDashboard.Item.Title" parent="Widget">
<item name="android:layout_marginBottom">#dimen/margin_tiny</item>
<item name="android:textAppearance">?android:textAppearanceLarge</item>
<item name="android:textColor">#09c</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">24sp</item>
</style>
<style name="Widget.SampleDashboard.Item.Description" parent="Widget">
<item name="android:textAppearance">?android:textAppearanceSmall</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
You can see the line on which the error is shown. Among the references I added to my project were
Xamarin.Android.Support.v4
Xamarin.Android.Support.v7.RecyclerView
That's All. As per the error message I suppose, 'Error retrieving parent for item' should mean it cannot find/locate a parent called 'Widget'. I did search for any nuget package like Xamarin Widget, anything of that name or similar name doesn't exist. At least my nuget package search cannot list/find anything like that. Or is it something to do with a style element definition called 'Widget' too in that xml file? So what is the actual correct thing to be done please, if someone could show me, it'd help me very much. Is it just a missing nuget package? If so what is the proper correct name of it please['widget'].
Please help me a little on this matter.
Thanks so much.
As I have used it before, the parent attribute's value is the parent style that you will start with, then override the various properties within there. For me, I have always used parent attribute values such as "#android:style/Theme.Holo.Light", .Dark, and so on. Unless there is a theme named Widget, I don't see this working.
PS. Obviously, the holo styles were first introduced in android 3.x/4.x, so I doubt that they would work in previous versions of android without including some other stuff to make them work. You used the Xamarin.Forms tag for the question, so this won't be a big deal since XF only runs on android 4 and later.
I use ActionBar in my Application. And I customized my own actionbar theme as the android developer site puts. unfortunately, My style doesn't work anyway. Every time my app is runned, there is an IllegalStateException thrown. And the detail is "You need to use a Theme.AppCompat theme (or descendant) with this activity.". Then, my custom style is here:
<resources>
<!-- the theme applied to the application or activity -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#8FB01C</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#CCE96B</item>
<item name="colorAccent">#303A0A</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- the theme applied to the application or activity -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="android:actionMenuTextColor">#color/action_bar_text_color</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="actionMenuTextColor">#color/action_bar_text_color</item>
</style>
<!-- ActionBar theme. -->
<style name="ActionBarTheme" parent="AppTheme">
<!-- when hide or show ActionBar frequently, use this attribute. -->
<item name="windowActionBarOverlay">true</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/TitleTextStyle</item>
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:backgroundStacked">#drawable/actionbar_background</item>
<item name="android:backgroundSplit">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/TitleTextStyle</item>
<item name="background">#drawable/actionbar_background</item>
<item name="backgroundStacked">#drawable/actionbar_background</item>
<item name="backgroundSplit">#drawable/actionbar_background</item>
</style>
<!-- action bar title text -->
<style name="TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#400040</item>
</style>
<!-- action bar tab text -->
<style name="TabTextStyle" parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#400040</item>
</style>
</resources>
And my manifest about this activity is here:
<activity
android:name=".HomeActivity"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:theme="#style/ActionBarTheme"
android:uiOptions="splitActionBarWhenNarrow" >
</activity>
But the strange thing is when I set android:theme="#style/ActionBarTheme" to android:theme="#style/Theme.Appcomat.Light", it works well. But the style is not what I want. So, it does confuse me. So, I want to know why my custom style doesn't work.
Alright, After the ActionBarTheme is changed into this:
<style name="ActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="colorPrimary">#8FB01C</item>
<item name="colorPrimaryDark">#CCE96B</item>
<item name="colorAccent">#4D4DFF</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="android:actionMenuTextColor">#color/action_bar_text_color</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="actionMenuTextColor">#color/action_bar_text_color</item>
<item name="windowActionBarOverlay">true</item>
</style>
it works well. Yep, here:
<style name="ActionBarTheme" parent="AppTheme">
It doesn't work. So I want to know why. Can't custom style be inherited, something wrong with my dev environment, or something else?
Maybe this is just the problem of your IDE. If you are using Eclipse, project-->clean, and then select your project, OK, then your project will rebuild. If you are using Android Studio, then, Build-->Rebuild Project or Clean Project, then take a look at the result.