android studio styles.xml cannot servolve symbol - android-studio

I made new style in styles.xml file and am trying to use it at the TextView objects in activity_main.xml file but I keep getting error: cannot resolve flag. What's wrong? I was trying to make other styles and it's the same error.
Styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#ffffff</item>
<item name="colorAccent">#19df19</item>
</style>
<style name="pytanie">
<item name="android:textSize">20sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:textStyle">italic</item>
<item name="android:textColor">000000</item>
<item name="android:textColorHighlight">#ff0000</item>
</style>
In main_activity.xml:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="pytanie numer 1"
android:textStyle="#styles/pytanie"/>

Related

Cannot change text size of com.google.android.material.tabs.TabItem in com.google.android.material.tabs.TabLayout

What am I missing to make the TabItem text bigger? I've gone through all similar questions and tried many different statements. I've tried applying a style to the TabLayout as well as the TabItem and nothing seems to work, the text size doesn't change.
Is this capability missing from the material design version?
Thanks
activity_main.xml
<com.google.android.material.tabs.TabLayout
style="#style/TabTheme"
android:layout_width="694dp"
android:layout_height="72dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabIndicatorHeight="6dp"
app:tabTextAppearance="#style/TabTheme">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clock In" />
styles.xml
<style name="TabTheme">
<item name="android:textSize">40dp</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">true</item>
<item name="android:textColor">#color/primaryDarkColor</item>
<item name="android:includeFontPadding">false</item>
</style>
I have also tried applying the following style to both TabLayout and TabItem
with no result:
<style name="CustomTabText" parent="TextAppearance.Design.Tab">
<item name="android:textSize">100sp</item>
</style>
It's working now. I've been creating a lot of test projects and this one still had the original theme definition by accident:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
I changed it to a material theme:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
That was the problem

switching to Theme.MaterialComponents from Theme.AppCompat shows white blank labels & buttons

I was using Material design 1.1.0
For Tabs with Viewpager2 . I updated it to '1.2.0-alpha05' Material library version it was working fine for single module but was crashing for another module where I've developed my custom material designed TextInputLayout. I changed theme from 'Theme.AppCompat.Light.NoActionBar' to Theme.MaterialComponents.Light.NoActionBar and crash fixed. After fixing crash and upgrading theme it is showing me white floating label , buttons , indiators etc anyone please guide me where am I doing wrong.?
GITHUb Issue Ticket Link :
https://github.com/material-components/material-components-android/issues/1207
TextInputLayout
Style.xml (Old File)
#color/white
#color/colorPrimary_New
#color/a465661
old file had conflict with material while using AppCompact with parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense" after updating to 1.2.0-alpha05 it was resolved but style background is not working now
Library
materialVersion = '1.2.0-alpha05'
"com.google.android.material:material:$materialVersion"
.XML (Design)
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
style="#style/contentInputLayoutStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_8dp"
android:paddingStart="5dp"
android:paddingLeft="5dp"
app:helperTextEnabled="true"
android:layout_marginLeft="#dimen/_8dp"
android:layout_marginEnd="#dimen/_8dp"
android:layout_marginRight="#dimen/_8dp"
app:errorEnabled="false"
app:layout_constraintBottom_toTopOf="#+id/errorTextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:hint="#string/EnterMobileNumber">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/textInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:gravity="start"
android:textDirection="anyRtl"
tools:text="0335510023"
android:background="#null"
android:paddingEnd="#dimen/inputFieldPadding_36dp"
android:paddingRight="#dimen/inputFieldPadding_36dp" />
</com.google.android.material.textfield.TextInputLayout>
Style.xml
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar" >
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/white</item>
<item name="colorPrimaryDark">#color/green</item>
<item name="colorAccent">#color/a465661</item>
</style>
<style name="contentInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<item name="boxStrokeColor">#color/border_stroke_grey</item>
<item name="android:textColor">#color/black</item>
<item name="android:textStyle">normal</item>
<item name="errorTextAppearance">#style/error_label</item>
<item name="counterOverflowTextAppearance">#style/AppTheme.TextFloatLabelAppearance</item>
<item name="android:actionOverflowButtonStyle">#style/AppTheme.TextFloatLabelAppearance
</item>
<item name="hintTextAppearance">#style/text_label</item>
</style>
<style name="text_label" parent="TextAppearance.Design.Hint">
<item name="android:textSize">#dimen/title_heading_12sp</item>
<item name="colorControlNormal">#color/black</item>
<item name="colorControlActivated">#color/black</item>
<item name="colorControlHighlight">#color/black</item>
</style>
<style name="text_label_green" parent="TextAppearance.Design.Hint">
<item name="android:textSize">#dimen/title_heading_12sp</item>
<item name="colorControlNormal">#color/green_field</item>
<item name="android:background">#null</item>
<item name="colorControlActivated">#color/green_field</item>
<item name="colorControlHighlight">#color/green_field</item>
</style>
<style name="AppTheme.TextFloatLabelAppearance" parent="text_label">
<!-- Floating label appearance here -->
<item name="android:textColor">#color/label_title_black</item>
<item name="android:textSize">#dimen/title_heading_12sp</item>
<item name="android:background">#android:color/transparent</item>
<item name="colorControlNormal">#color/label_title_black</item>
<item name="colorControlHighlight">#color/label_title_black</item>
<item name="colorControlActivated">#color/label_title_black</item>
</style>
<style name="material_edit_text" parent="Widget.AppCompat.EditText">
<item name="android:paddingStart">50dp</item>
<item name="android:paddingLeft">50dp</item>
<item name="android:background">#null</item>
<item name="android:textSize">16sp</item>
</style>
<style name="error_label" parent="TextAppearance.Design.Hint">
<item name="android:textSize">0sp</item>
<item name="android:textColor">#color/red</item>
<item name="android:visibility">gone</item>
</style>
<style name="BtnCustomStyle">
<item name="android:background">#drawable/btn_confirm_selector</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">15dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">46dp</item>
<item name="android:layout_marginStart">10dp</item>
<item name="android:layout_marginEnd">10dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:foreground">android:attr/selectableItemBackground</item>
</style>
Style(v27).xml (deleted file)
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/white</item>
<item name="colorPrimaryDark">#color/colorPrimary_New</item>
<item name="colorAccent">#color/a465661</item>
<item name="android:windowLayoutInDisplayCutoutMode">never</item>
</style>
Update
"Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
this line was causing crash while using appCompact Theme.
Read topic on material design UI update. According to this document I've to add few attributes that are below!
<!-- New MaterialComponents attributes. -->
<item name="colorOnPrimary">#color/whitee</item>
<item name="colorOnSecondary">#color/colorPrimary_New</item>
<item name="colorOnSurface">#color/a465661</item>-->
<item name="colorSurface">#color/a465661</item>-->
<item name="colorOnBackground">#212121</item>-->
<item name="android:colorBackground">#color/background</item>
<item name="colorError">#F44336</item>-->
<item name="colorOnError">#FFFFFF</item>
but , I tried changing color for TextInputLayout its working fine but for button its not. anyone please guide me how to handle this with new material design.?
update :
android:theme="#style/Theme.MaterialComponents.Light"
add the above-mentioned theme to the widget and it will solve your issue.for example.
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:theme="#style/Theme.MaterialComponents.Light"
app:itemIconTint="#drawable/bottom_navigation_background"
app:itemTextColor="#drawable/bottom_navigation_background"
android:layout_alignParentBottom="true"
app:menu="#menu/navigation"
app:labelVisibilityMode="labeled"
app:itemTextAppearanceActive="#style/BottomNavigationActive"
app:itemTextAppearanceInactive="#style/BottomNavigationInactive" />

Cannot resolve symbol 'ThemeOverlay'. Validates resource references in Android XML files

I got an error "Cannot resolve symbol 'ThemeOverlay'. Validates resource references in Android XML files". Here is the code:
<resources>
<!-- 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>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
on creating styles.xml in Android Studio. How can I resolve it.

Centering the home/homeasup and action menu in an appcompat actionbar

seems like I am the only one on SO with such problem. Why, android, why ?...
have a look at the image. Only the title is centered (phew). The other two items... help!
here is the relevant xml mojo
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/dl_base"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context="com.farmdog.farmdog.HelperActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:paddingTop="#dimen/appbar_padding_topbottom"
android:paddingBottom="#dimen/appbar_padding_topbottom"/>
</android.support.design.widget.AppBarLayout>
and the styles:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<!-- colorPrimaryDark wont work on API level < 21 -->
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowBackground">#color/mainBkgndHard</item>
<item name="android:textColor">#color/appTextColor</item>
<item name="android:buttonStyle">#style/ButtonTheme</item>
<!-- attempt taking actionbar shadow away -->
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="actionMenuTextColor">#color/appTextColor</item>
<item name="titleTextColor">#color/appTextColor</item>
<item name="colorControlNormal">#color/appTextColor</item>
<item name="android:layout_centerVertical">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorPrimary">#color/colorActionBar</item>
</style>
You have set toolbar paddingTop and paddingBottom. You should remove them. I hope it will help resolve your problem.

Spinner drop down menu items color (Android)

So I have a spinner and I was successful in changing the color of the selected item but I am not able to change the color of the items in the drop down menu
This is my spinner_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textColor="#33CCFF"
/>
and this is my styles.xml
<resources>
<style name="AppTheme" parent="android:Theme.Light" >
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem.Color</item>
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
</style>
<style name="SpinnerItem.DropDownItem.Color" parent="#android:style/Widget.DropDownItem.Spinner">
<item name="android:textColor">#4FBDE8</item>
</style>
<style name="SpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">#4FBDE8</item>
</style>
</resources>
is there an XML way I can do it in ?
Here is the solution I found on another stackoverflow thread
<style name="Theme.NoTitleBar.WithColoredSpinners" parent="#android:style/Theme.NoTitleBar">
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>
<style name="SpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">#00FF00</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="#android:style/Widget.DropDownItem.Spinner">
<item name="android:textColor">#FF0000</item>
</style>
While specifying a layout resource file for the spinner, you have to set it at two places.
While declaring a new ArrayAdapter
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, categories);
While setting the dropDownViewResource on the array adapter.
dataAdapter.setDropDownViewResource(R.layout.spinner_item_dropdown);
Notice that two different layout files have been used. You can customize your views in the following manner, by defining the styles and using these styles as theme in the respective layouts.
<style name="SpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">#color/white</item>
<item name="android:background">#color/black</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="#android:style/Widget.DropDownItem.Spinner">
<item name="android:textColor">#color/black</item>
</style>
Hope this helps.

Resources