material-components-android-codelabs
material-components-android-codelabs copied to clipboard
MDC - 102 Java: Documentation regarding issues + Style Theme issues
Description
1. When importing the Toolbar class, the documentation was importing import android.widget.Toolbar instead of import androidx.appcompat.widget.Toolbar
2. Screenshot of the home screen is not correct. Toolbar color is colorAccent. But the screenshot is showing the toolbar color is colorPrimary
3. In Section: Create a grid of cards ProductGridFragment.java Line: 39
The tutorial is saying: recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2, GridLayoutManager.VERTICAL, false));
But it should be like this here: https://github.com/material-components/material-components-android-codelabs/blob/9e0db3164670b423e029816745199fd7a2f3e2fe/java/shrine/app/src/main/java/com/google/codelabs/mdc/java/shrine/ProductGridFragment.java#L39
URL: https://codelabs.developers.google.com/codelabs/mdc-102-java/index.html?index=..%2F..io2019#4
Expected behavior + Solution Proposal
1. The Toolbar should be getting imported from androidx class.
Solution:
In ProductGridFragment.java
import androidx.appcompat.widget.Toolbar;
2. Toolbar should be of Shrine Theme.
Solution: In values/styles.xml Replace
<style name="Widget.Shrine.Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="android:background">?attr/colorAccent</item>
with
<style name="Widget.Shrine.Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="android:background">@color/colorPrimary</item>
3. Here is the correct code: https://github.com/material-components/material-components-android-codelabs/blob/102-complete/java/shrine/app/src/main/java/com/google/codelabs/mdc/java/shrine/ProductGridFragment.java
**Codelab details **
- Level (MDC-102)
- Language (Java)
- Link to the codelab at the step with the issue (ex: https://codelabs.developers.google.com/codelabs/mdc-102-java/index.html?index=..%2F..io2019#2)