google-developer-training / first-android-app

Repository for Build Your First Android App codelabs (Java and Kotlin)
7 stars 6 forks source link

First Android App codelab: #177

Open halso opened 2 years ago

halso commented 2 years ago

Hi,

Great tutorial, so thanks for that.

One thing that doesn't work on Page 7 of the tutorial at:

https://developer.android.com/codelabs/build-your-first-android-app#6

is:-

Step 2: Add a background color for the buttons In the layout, add a background color to each of the buttons. (You can either edit the XML in fragment_first.xml or use the Attributes panel, whichever you prefer.)

android:background="@color/buttonBackground"

It seems the button background gets set to:-

@color/purple_700

in themes.xml, and so the buttons stay purple, when your tutorial shows them changing to light blue.

Probably this tutorial was written before this theme was the default for this demo app.

The fix may be something like adding to themes.xml:-

<style name="Theme.StevesFirstTestApp.Buttons">
    <item name="colorOnPrimary">@color/black</item>
    <item name="colorPrimary">@color/buttonBackground</item>
</style>

and in fragment_first.xml updating the theme id to that for all three buttons:-

<Button
    android:id="@+id/count_button"
    android:theme="@style/Theme.StevesFirstTestApp.Buttons"

Thanks

Steve

Version info:

Emulator: Pixel 2 API 30

Android Studio Bumblebee | 2021.1.1 Build #AI-211.7628.21.2111.8092744, built on January 19, 2022 Runtime version: 11.0.11+0-b60-7590822 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 12.1 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 16 Registry: external.system.auto.import.disabled=true, ide.instant.shutdown=false