android checkbox style not working on ICS - android

My checkbox styles are being applied on android v5+, but not on v4.x
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:textColor">#color/ui_text</item>
<item name="android:windowAnimationStyle">#null</item>
<item name="android:textStyle">bold</item>
<item name="android:alertDialogStyle">#style/AppDlg</item>
<item name="android:radioButtonStyle">#style/RadioButtonStyle</item>
<item name="android:checkboxStyle">#style/CheckBoxStyle</item>
<item name="android:editTextStyle">#style/EditTextStyle</item>
</style>
<style name="RadioButtonStyle" parent="CheckBoxStyle">
<item name="android:textColor">#color/ui_text</item>
<item name="android:textStyle">bold</item>
<item name="android:button">#drawable/radiobutton</item>
</style>
<style name="CheckBoxStyle" parent="#android:style/Widget.Holo.CompoundButton.CheckBox">
<item name="android:textColor">#color/ui_text</item>
<item name="android:paddingLeft">8dip</item>
<item name="android:drawablePadding">12dip</item>
<item name="android:textStyle">bold</item>
<item name="android:button">#drawable/checkbox</item>
<item name="android:buttonTint">#color/primary</item>
<item name="android:layout_width">#dimen/checkbox_size</item>
<item name="android:layout_height">#dimen/checkbox_size</item>
</style>
...
I am compiling against, and targeting SDK 25, with a minimum SDK of 15. I am using support-v4:25.3.0, appcompat-v7:25.3.0, design:25.3.0
Android Studio gives me an error in styles.xml about buttonTint requiring a minimum API level of 21, but even with this line removed I get the same behavior (checkboxes being styled on 5.x, but not on 4.x)

It seems I needed to add the following lines to styles.xml
<item name="checkboxStyle">#style/CheckBoxStyle</item>
<item name="radioButtonStyle">#style/RadioButtonStyle</item>
to compliment the lines that were already there...
<item name="android:radioButtonStyle">#style/RadioButtonStyle</item>
<item name="android:checkboxStyle">#style/CheckBoxStyle</item>
!

Related

MaterialDatePicker calendar numbers are not aligned on the center

Description: Numbers are not aligned on the center
Expected behavior: Numbers should be aligned on the center
Source code:
NOTE: The same behavior occured even before adding any style
<style name="OeamtcThemeOverlay_MaterialCalendar"
parent="#style/Theme.MaterialComponents.Light.Dialog">
<item name="android:colorAccent">#color/oeamtc_accent</item>
<item name="headerLayout">#style/Oeamtc_MaterialCalendar_Header</item>
<item name="android:colorButtonNormal">#color/oeamtc_accent</item>
<item name="android:button">#color/oeamtc_accent</item>
<item name="buttonBarPositiveButtonStyle">#style/ThemeMaterialCalendarButton</item>
<item name="buttonBarNegativeButtonStyle">#style/ThemeMaterialCalendarButton</item>
<item name="materialCalendarStyle">#style/Oeamtc_MaterialCalendar</item>
<item name="materialButtonStyle">#style/ThemeMaterialButton</item>
</style>
<style name="Oeamtc_MaterialCalendar"
parent="#style/Widget.MaterialComponents.MaterialCalendar">
<item name="rangeFillColor">#color/oeamtc_accent_transparent_50</item>
<item name="dayStyle">#style/Oeamtc_CalendarDay</item>
<item name="dayTodayStyle">#style/Oeamtc_CalendarToday</item>
<item name="daySelectedStyle">#style/Oeamtc_CalendarSelected</item>
</style>
<style name="ThemeMaterialCalendarButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">#color/oeamtc_accent</item>
</style>
<style name="ThemeMaterialButton" parent="Widget.MaterialComponents.Button">
<item name="android:textColor">#color/white</item>
<item name="android:backgroundTint">#color/oeamtc_accent</item>
</style>
<style name="Oeamtc_CalendarDay" parent="Test.Widget.MaterialComponents.MaterialCalendar.Day">
<item name="itemTextColor">#color/black</item>
<item name="itemFillColor">#color/transparent</item>
<item name="itemStrokeColor">#color/white</item>
<item name="itemStrokeWidth">0dp</item>
<item name="android:gravity">center</item>
<item name="itemShapeAppearance">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
<item name="itemShapeAppearanceOverlay">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
</style>
<style name="Oeamtc_CalendarSelected" parent="">
<item name="itemFillColor">#color/oeamtc_accent</item>
<item name="itemTextColor">#color/white</item>
<item name="itemStrokeColor">#color/oeamtc_accent</item>
<item name="itemStrokeWidth">0dp</item>
<item name="itemShapeAppearance">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
<item name="itemShapeAppearanceOverlay">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
</style>
<style name="Oeamtc_CalendarToday" parent="">
<item name="itemTextColor">#color/black</item>
<item name="itemStrokeColor">#color/oeamtc_accent</item>
<item name="itemFillColor">#color/white</item>
<item name="itemStrokeWidth">3dp</item>
<item name="itemShapeAppearance">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
<item name="itemShapeAppearanceOverlay">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
</style>`
Android API version: 29
Material Library version: 1.1.0
Device: Oneplus 6t and all nexus emulators
I found the reason this happened. Apparently the main theme of the app has to inherit Material theme.

Android Support Library Build v26.X.X Build Error: Attribute “fontFamily” already defined with incompatible format

I updated my support build library to 26.x.x from 25.4.0 and i get
AGPBI: {"kind":"error","text":"Original attribute defined here.","sources":[{"file":"/Users/me/AndroidStudioProjects/Mail/mail/build/intermediates/res/merged/dev/debug/values/values.xml","position":{"startLine":40}}],"original":"","tool":"AAPT"}
/Users/me/AndroidStudioProjects/Mail/mail/build/intermediates/res/merged/dev/debug/values/values.xml:373: error: Attribute "fontFamily" already defined with incompatible format.
/Users/me/AndroidStudioProjects/Mail/mail/build/intermediates/res/merged/dev/debug/values/values.xml:41: Original attribute defined here.
I did to clean project->rebuild, invalidate and restart studio, remove prefix android from android:fontFamily(now just fontFamily in item), exclude modules from others libraries (there were conflicts).
My styles.xml:
<style name="CurrentTheme" parent="#style/AppTheme.Base">
<!-- Common styles -->
<item name="android:windowBackground">#color/bg</item>
<item name="android:colorBackground">#color/bg</item>
<item name="android:autoCompleteTextViewStyle">#style/AutoCompleteTextView</item>
<item name="android:actionOverflowButtonStyle">#style/OverFlow.Light</item>
<item name="actionOverflowButtonStyle">#style/OverFlow.Light</item>
<item name="actionModeStyle">#style/MessagesListActionMode</item>
<item name="actionModeCloseDrawable">#drawable/ic_action_cancel</item>
<item name="android:itemTextAppearance">#style/myCustomMenuTextApearance</item>
<item name="searchViewStyle">#style/MySearchViewStyle</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorAccent">#color/logo_color</item>
<item name="colorControlNormal">#color/col888</item>
<item name="colorControlActivated">#color/logo_color</item>
<item name="homeAsUpIndicator">#drawable/ab_back_button_bg_states</item>
<item name="alertDialogTheme">#style/CurrentTheme.AlertDialog</item>
<item name="actionMenuTextColor">#color/logo_color</item>
<item name="toolbarStyle">#style/CurrentTheme.Toolbar</item>
</style>
<style name="CurrentTheme.WithoutPreview" parent="CurrentTheme.Transparent" >
<item name="android:windowDisablePreview">true</item>
</style>
<style name="CurrentTheme.Transparent" parent="CurrentTheme" />
<style name="TodoWelcomeTheme" parent="#style/CurrentTheme" />
<style name="CurrentTheme.Toolbar" parent="#style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">72dp</item>
</style>
<style name="CurrentTheme.AlertDialog" parent="#style/Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#color/color14</item>
</style>
<style name="CurrentTheme.AlertDialog.ButtonBarStyle" />
<style name="OverFlow.Light" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:contentDescription">#string/overflow_expose_cd</item>
<item name="android:src">#drawable/ic_overflow_blue</item>
</style>
<style name="myCustomMenuTextApearance" parent="#android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">#drawable/text_selector</item>
</style>
<style name="AppTheme.Base" parent="#style/Theme.AppCompat.Light.DarkActionBar" />
<style name="MySearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="searchIcon">#android:color/transparent</item>
<item name="closeIcon">#drawable/ic_close_white_24dp</item>
</style>
<style name="MessagesListActionMode" parent="Widget.AppCompat.ActionMode">
<item name="background">#color/toolbar_am_bg</item>
<item name="android:background">#color/toolbar_am_bg</item>
<item name="android:height">56dp</item>
<item name="android:titleTextStyle">#style/ActionModeTitle</item>
</style>
<style name="ActionModeTitle" parent="TextAppearance.AppCompat.Widget.ActionMode.Title">
<item name="android:textColor">#color/actionbar_text_color</item>
<item name="android:textSize">#dimen/font_20pt</item>
<item name="android:textStyle">normal</item>
<item name="fontFamily">#string/font_roboto_medium</item>
</style>
<style name="TestStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorAccent">#color/color2</item>
</style>
<style name="CurrentTheme.Widget" />
<style name="CurrentTheme.Widget.SocialButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginLeft">5dp</item>
</style>
<style name="OtherMail.floating_text_view" parent="android:style/Widget.TextView">
<item name="android:textSize">#dimen/font_12pt</item>
<item name="android:textColor">#color/color4</item>
</style>
<style name="OtherMail.edit_text" parent="android:style/Widget.EditText">
<item name="android:textSize">#dimen/font_16pt</item>
<item name="android:singleLine">true</item>
<item name="android:background">#drawable/textedit_bg_state</item>
<item name="android:textColor">#color/color7</item>
<item name="android:textColorHint">#color/color7</item>
</style>
</style>
Etc.
If for right answer i should give you more information, tell me.
I found the library which have incorrect support library version. I excluded support library group(Example this) inside it(or I could remove that library or update its), but it didn't work for me and I update library and(but exclude should work too, i think) my project was built.
Problem:
The library from which the error was thrown out is shown below:
My logs didn't show to me where was the problem(Indirectly, in the generated file there was a mention of roboto).
Decisions:
1) You can exclude group which throws error:
2) Or update it:
I hope my answer will help someone.

debug/AndroidManifest.xml elements not recognized during build in AndroidStudio

I am working on porting an existing app to a new setup and I got almost everything working, but when I tried to build the project, I got the error that some of the elements in the debug/AndroidManifest.xml are not recognized. Here are some screenshots:
Any idea why that might be happening and how to fix that?
This is my styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/white</item>
<item name="android:colorBackground">#color/white</item>
</style>
<style name="home_page_buttons">
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:textStyle">bold</item>
<item name="android:color">#color/white</item>
<item name="android:layout_height">45dip</item>
<!-- <item name="android:background">#drawable/white_button</item> -->
</style>
<style name="home_page_two_buttons">
<item name="android:textStyle">bold</item>
<item name="android:color">#color/white</item>
<item name="android:layout_height">45dip</item>
<!-- <item name="android:background">#drawable/white_button</item> -->
</style>
<!-- Information Pages -->
<style name="instruction_text">
<item name="android:padding">10px</item>
<item name="android:textSize">16sp</item>
</style>
<style name="instruction_quote">
<item name="android:padding">10px</item>
<item name="android:textSize">12sp</item>
</style>
<style name="instruction_heading">
<item name="android:padding">10px</item>
<item name="android:textSize">17sp</item>
<item name="android:textColor">#color/light_best_blue</item>
</style>
</resources>
You mentioned the android:theme as "AppBaseTheme" but i do not see that style in your style.xml file.

Cant change colorButtonNormal value to all buttons

I am trying to make all buttons in my app have default color using colorButtonNormal in my style.
It works nice on API 21 and above but under API 21 it only changes the background of some buttons and i dont know what is going wrong.
styles.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentOverlay">#null</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="colorPrimary">#color/btn_login</item>
<item name="colorPrimaryDark">#color/bg_login</item>
<item name="colorAccent">#color/btn_login</item>
<item name="colorButtonNormal">#color/btn_login</item>
</style>
</resources>
v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentOverlay">#null</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:alertDialogTheme">#style/AlertDialogCustom</item>
<item name="android:colorButtonNormal">#color/btn_login</item>
<item name="colorPrimary">#color/btn_login</item>
<item name="colorPrimaryDark">#color/bg_login</item>
<item name="colorAccent">#color/btn_login</item>
</style>
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:colorPrimary">#color/btn_login</item>
<item name="android:colorAccent">#color/btn_login</item>
<item name="colorAccent">#color/btn_login</item>
<item name="colorPrimary">#color/btn_login</item>
<item name="colorPrimaryDark">#color/bg_login</item>
</style>
<style name="Preference" parent="Theme.AppCompat.Light">
<item name="android:textColorPrimary">#color/black</item>
<item name="android:colorPrimary">#color/btn_login</item>
<item name="android:colorAccent">#color/btn_login</item>
<item name="android:editTextColor">#color/black</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:alertDialogTheme">#style/AlertDialogCustom</item>
<item name="colorAccent">#color/btn_login</item>
</style>
<style name="EditTextThemeCustom" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:editTextColor">#color/black</item>
<item name="android:textColor">#color/black</item>
<item name="colorAccent">#color/btn_login</item>
</style>
</resources>
Result:
Lollipop
and
Kitkat
Any suggestions?
Add to your styles.xml
<style name="ColoredButton" parent="Widget.AppCompat.Button">
<item name="colorButtonNormal">#color/btn_login</item>
</style>
and then use
android:theme="#style/ColoredButton"
as one of your buttons' attributes
The buttons you inflate will get automatically translated to AppCompatButton.
Wherever you have new Button(context) you need to use new AppCompatButton(context) instead for Material theme colors to apply.
I was getting this issue in old devices(<21) because, my activity was extending just activity when I make in it extend AppCompatActivity, in old devices also it is working perfect.

Change generated action bar theme from Android Asset Studio

I have used Android Asset Studio to generate action bar style, however i woul like to do some changes, which I was unable to do in Studio, so I edited generated theme but lot of things was just ignored, and I just can't figure out how things work.
There is example:
`
<style name="Theme.Myactionbar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_myactionbar</item>
<item name="popupMenuStyle">#style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Myactionbar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Myactionbar</item>
<item name="actionDropDownStyle">#style/DropDownNav.Myactionbar</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Myactionbar</item>
<item name="actionModeBackground">#drawable/cab_background_top_myactionbar</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_myactionbar</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Myactionbar</item>
</style>
<style name="ActionBar.Solid.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_myactionbar</item> //THIS IS GREEN
<item name="backgroundStacked">#drawable/ab_solid_myactionbar</item>//THIS IS GREEN
<item name="backgroundSplit">#drawable/ab_bottom_solid_myactionbar</item>//THIS IS GREEN
<item name="progressBarStyle">#style/ProgressBar.Myactionbar</item>
</style>
<style name="ActionBar.Transparent.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_myactionbar</item>
<item name="progressBarStyle">#style/ProgressBar.Myactionbar</item>
</style>
<style name="PopupMenu.Myactionbar" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example </item>
</style>
<style name="DropDownListView.Myactionbar" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_myactionbar</item>
</style>
<style name="ActionBarTabStyle.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_myactionbar</item>
</style>
<style name="DropDownNav.Myactionbar" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_myactionbar</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_myactionbar</item>
<item name="android:dropDownSelector">#drawable/selectable_background_myactionbar</item>
</style>
<style name="ProgressBar.Myactionbar" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_myactionbar</item>
</style>
<style name="ActionButton.CloseMode.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_myactionbar</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Myactionbar.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Myactionbar</item>
</style>
Everything was like in generator, but then i tried the simplest change, that is the color, so I edited style name=ActionBar.Solid.Myactionbar and put there som other drawables from other generated style.
It looked like this :
<style name="Theme.Myactionbar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_myactionbar</item>
<item name="popupMenuStyle">#style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Myactionbar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Myactionbar</item>
<item name="actionDropDownStyle">#style/DropDownNav.Myactionbar</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Myactionbar</item>
<item name="actionModeBackground">#drawable/cab_background_top_myactionbar</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_myactionbar</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Myactionbar</item>
</style>
<style name="ActionBar.Solid.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_example</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_myactionbar</item>
<item name="progressBarStyle">#style/ProgressBar.Myactionbar</item>
</style>
but nothing happend, and changed drawables supposed to be gray. I was wandering if anybody did this before and why this isnt working? Thank you
Ok I figured it out, there is values-v14 folder for styles for api level 14 and above, so you have to change these values too.

Categories

Resources