I am currently digging through the code of the Google IO 2019 android app.
In the styles.xml line 77 it says:
<style name="TextAppearance.IOSched.Body2" parent="TextAppearance.MaterialComponents.Body2" />
But where can I find the definition of the parent TextAppearance.MaterialComponents.Body2? I already have the IO project locally in my Android Studio, in case that helps to resolve what is behind that definition.
Thanks!
It is defined in the Material Components library.
Currently it is:
<style name="TextAppearance.MaterialComponents.Body2" parent="TextAppearance.AppCompat.Body1">
<item name="fontFamily">sans-serif</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:letterSpacing">0.0178571429</item>
</style>
You can find here the latest implementation.
Related
I needed to hide the default overflow icon (3 dots) so I wrote the code below. I was working fine until I updated android studio yesterday, after that its giving me this error:
D:\Android Projects\myapp\app\src\main\res\values\styles.xml:18:5-21:13: AAPT: error: expected color reference but got (raw string) null.
Here's the code:
<style name="MaterialTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryDarkColor</item>
<item name="colorAccent">#color/secondaryColor</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:actionOverflowButtonStyle">#style/CustomActionOverflowButtonStyle</item>
</style>
<style name="CustomActionOverflowButtonStyle">
<item name="android:width">8dp</item>
<item name="android:src">null</item>
</style>
What am I doing wrong? Please help!
change this
<item name="android:src">null</item>
to
<item name="android:src">#null</item>
This code
<style name="listViewPrefs" parent="#android:Widget.ListView">
...
</style>
produces the following Android Rescources Validation error:
Invalid parent reference: expected #style. There should be no cycles in
resource definitions as this can lead to runtime exceptions.
How can this be fixed?
I think you have to use like,
<style name="listViewPrefs" parent="#android:style/Widget.ListView">
...
</style>
Am getting error while trying to build the application.
Android resource linking failed
error: resource style/Base.V28.Theme.AppCompat.Light (aka
com.xxx.xxxx/Base.V28.Theme.AppCompat.Light) not found.
error: failed linking references.
build.gradle
compileSdkVersion 28
also in sdk manager platform tools for 28 is installed
but am not getting the cause of this issue
style.xml
**<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/card_bg</item>
<item name="colorAccent">#color/black_dim</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowAnimationStyle">#null</item>
<item name="autoCompleteTextViewStyle">#style/cursorColor</item>
</style>
<style name="AppThemeChange" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
</style>
<style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">#dimen/tab_text_size</item>
<item name="android:textAllCaps">true</item>
</style>
I am new in coding of any kind, but I have just fixed this error by following a solution in another StackOverflow thread that says to do the following:
Give in the command
gradlew.bat --info clean build
I gave this command into the end of my build.gradle file and it showed me AS WELL as fixed the error!
I'm so happy! This command should be the answer to many problems!
I'm receiving the following 2 errors when trying to build my Android project with Gradle:
Error:(598) Attribute "font" already defined with incompatible format.
Error:(2209, 39) String types not allowed (at 'android:typeface' with value 'roboto_medium').
I've looked online elsewhere but can't find the answer to these issues, any clarification or help is much appreciated.
Update:
Here is the stacktrace:
AGPBI: {"kind":"error","text":"Attribute \"font\" already defined with incompatible format.","sources":[{"file":"/Users/johnbyrne/Documents/myapp-android/MyApp/app/build/intermediates/res/merged/development/debug/values/values.xml","position":{"startLine":597}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Original attribute defined here.","sources":[{"file":"/Users/johnbyrne/Documents/myapp-android/MyApp/app/build/intermediates/res/merged/development/debug/values/values.xml","position":{"startLine":417}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"String types not allowed (at \u0027android:typeface\u0027 with value \u0027roboto_medium\u0027).","sources":[{"file":"/Users/johnbyrne/Documents/myapp-android/MyApp/app/build/intermediates/res/merged/development/debug/values/values.xml","position":{"startLine":2208,"startColumn":38,"startOffset":158093,"endColumn":51,"endOffset":158106}}],"original":"","tool":"AAPT"}
Failed to generate resource table for split ''
/Users/johnbyrne/Documents/myapp-android/MyApp/app/build/intermediates/res/merged/development/debug/values/values.xml:598: error: Attribute "font" already defined with incompatible format.
/Users/johnbyrne/Documents/myapp-android/MyApp/app/build/intermediates/res/merged/development/debug/values/values.xml:418: Original attribute defined here.
/Users/johnbyrne/Documents/myapp-android/MyApp/app/build/intermediates/res/merged/development/debug/values/values.xml:2209: error: Error: String types not allowed (at 'android:typeface' with value 'roboto_medium').
My styles.xml looks like this:
<resources>
<style name="ButtonLight">
<item name="android:typeface">roboto_medium</item>
<item name="android:textSize">#dimen/text_size_button</item>
<item name="android:textColor">#color/black_87</item>
<item name="colorAccent">#color/white</item>
<item name="android:lineSpacingExtra">-2sp</item>
<item name="android:gravity">center_vertical</item>
</style>
</resources>
If you are using Custom fonts in your app then please check once Font or Typeface implemented correctly.
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-black" // roboto black
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0)
<style name="ButtonLight">
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textSize">#dimen/text_size_button</item>
<item name="android:textColor">#color/black_87</item>
<item name="colorAccent">#color/white</item>
<item name="android:lineSpacingExtra">-2sp</item>
<item name="android:gravity">center_vertical</item>
</style>
Try this.
I got the following error after updating my android sdk revision to r12.
error: Error retrieving parent for item: No resource found that matches the given name '#android:style/AlertDialog'.
Here is my xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDialogTheme" parent="#android:style/AlertDialog">
<item name="android:windowFrame">#null</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowAnimationStyle">#android:style/Theme.Dialog</item>
</style>
</resources>
I didn't change anything in the code and the only thing that I did was upgraded the Android SDK.
android:style/AlertDialog is not a public style and you should not use it. Please refer to this thread How to change theme for AlertDialog
Finaly i found the answer . i know its not the proper way but it works for now.
I managed to fix it by replacing the platform-tools_r06 with platform-
tools_r05 in android sdk folder
you can dowload platform-tools-r05 from here.