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.
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've been making a chat for a project of mine but how to change the color of these pointers?
Setting the android:textCursorDrawable attribute to #null should result in the use of android:textColor as the cursor color.
or you can use Style look like this
<style name="AppTheme.EditText" parent="#style/Widget.AppCompat.EditText">
<item name="android:textColor">#color/white</item>
<item name="android:textColorHint">#8AFFFFFF</item>
<item name="android:background">#drawable/edit_text_background</item> // background (bottom line at this case)
<item name="android:textCursorDrawable">#color/white</item> // Cursor
<item name="android:textSelectHandle">#drawable/my_white_icon</item> // For pointer normal state and copy text state
<item name="android:textSelectHandleLeft">#drawable/my_white_icon</item>
<item name="android:textSelectHandleRight">#drawable/my_white_icon</item>
</style>
hope it help
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.
Given the following style in file: res/values/styles.xml
<style name="GiftCardFragment.TitleLLLabelTV">
<item name="android:paddingStart">5dp</item>
<item name="android:paddingLeft">5dp</item>
</style>
android:paddingStart is only valid in Android platform 17 and above, so then I would create a new styles.xml file in "res/values-v17/styles.xml".
But the question is: Do I have to repeat the whole style, or could I just add the styles I want to add extra (alternatively override) for a given platform and above in "res/values-v17/styles.xml"? Like:
<style name="GiftCardFragment.TitleLLLabelTV">
<item name="android:paddingStart">5dp</item>
</style>
And then Android would merge then at runtime. Am I correct? Any pointing in right direction appreciated, I couldnt find documentation really covering this case.
I have this style.xml inside my Android app:
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="OrangeTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/OrangeTheme.OrangeActionBar</item>
<item name="android:windowActionBar">true</item>
</style>
<style name="OrangeTheme.OrangeActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#color/orange</item>
<item name="background">#color/orange</item>
<item name="android:backgroundStacked">#color/orange</item>
<item name="android:backgroundSplit">#color/orange</item>
<item name="android:titleTextStyle">#style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/black</item>
</style>
I have searched StackOverflow and Google, but nothing helped. I wasn't able to change the ActionBar background color.
Inside my MainActivity, I use this code:
public void restoreActionBar() {
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
}
I tried not to use AppCompat, but then my name has a lot of errors. It extends ActionBarActivity. If I change it to FragmentActivity I can't use getSupportActionBar() and without it my getActionBar(), is always null.
minSdkVersion 19
targetSdkVersion 21
So right now I am not able to change it. I tried renaming the parent of my style theme. I tried using andrioud:background and background. The only thing that is changing is when I use another parent like
Theme.App.Compat.Light or Theme.AppCompat.Light.DarkActionBar.
Does someone have an idea, how I could be able to change the colors and other stuff, on runtime?
With new AppCompat-v7 (v21) you can use new color theming attributes. See here.
Or alternatively you have to use <item name="actionBarStyle"> property (without prefix android).
To use background color with AppCompat, you need to also define the item name without the android: attribute.
for example:
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:background">#color/action_bar_background</item>
<item name="background">#color/action_bar_background</item> //<--background item without the android attribute
</style>
and then in your custom theme do the same thing for the custom actionbar style:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>