material-components / material-components-android-codelabs

Codelabs for Material Components for Android (MDC-Android)
Apache License 2.0
220 stars 160 forks source link

MDC-102 Missing Attributes in shr_product_grid_fragment.xml #53

Open Lucienest opened 4 years ago

Lucienest commented 4 years ago

android:background="@color/colorPrimary" attribute is missing from the shr_product_grid_fragment.xml as a result the Toolbar Color appears to be Grayed out instead of showed in the Tutorial MDC-102


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
   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"
   tools:context=".ProductGridFragment">

   <com.google.android.material.appbar.AppBarLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content">

       <androidx.appcompat.widget.Toolbar
           android:id="@+id/app_bar"
           android:background="@color/colorPrimary"
           style="@style/Widget.Shrine.Toolbar"
           android:layout_width="match_parent"
           android:layout_height="?attr/actionBarSize"
           app:navigationIcon="@drawable/shr_menu"
           app:title="@string/shr_app_name" />
   </com.google.android.material.appbar.AppBarLayout>

</FrameLayout>
![image](https://user-images.githubusercontent.com/61408704/75141642-51ebd480-56e9-11ea-802b-c991d0eff2c1.png)
Maksym5732005 commented 4 years ago

Actually, the Toolbar has the background reference. You can see it inside the style "Widget.Shrine.Toolbar".

    <style name="Widget.Shrine.Toolbar" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">?attr/colorAccent</item>
        . . .
    </style>

But, the reference is wrong, it refers to "?attr/colorAccent" instead of "?attr/colorPrimary" This issue from Java and Kotlin projects as well