Skip to content

Instantly share code, notes, and snippets.

View ricknout's full-sized avatar

Nick Rout ricknout

View GitHub Profile
@ricknout
ricknout / mdc_button_custom_gradient_background.xml.diff
Last active January 19, 2023 09:27
MDC-Android button custom gradient background
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
-<Button
+<androidx.appcompat.widget.AppCompatButton
android:background="@drawable/bg_button_gradient"
+ android:textAppearance="?attr/textAppearanceButton"
... />
@ricknout
ricknout / appcompat_app_theme.xml
Created April 3, 2020 13:10
AppCompat app theme
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="Theme.App" parent="Theme.AppCompat.*">
<item name="colorPrimary">@color/navy_700</item>
<item name="colorPrimaryDark">@color/navy_900</item>
<item name="colorAccent">@color/green_300</item>
</style>
@ricknout
ricknout / mdc_shape_theming.xml.diff
Created April 3, 2020 11:51
MDC-Android shape theming
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="Theme.App" parent="Theme.MaterialComponents.*">
...
+ <item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.App.SmallComponent</item>
+ <item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.App.MediumComponent</item>
+ <item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.App.LargeComponent</item>
</style>
+<style name="ShapeAppearance.App.SmallComponent"
@ricknout
ricknout / mdc_background_update.xml.diff
Created April 3, 2020 11:49
MDC-Android background update
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<com.google.android.material.bottomnavigation.BottomNavigationView
- android:background="@android:color/white"
... />
<com.google.android.material.card.MaterialCardView
- app:cardCornerRadius="2dp"
...>
...
@ricknout
ricknout / mdc_type_theming.xml.diff
Last active January 19, 2023 09:27
MDC-Android type theming
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="Theme.App" parent="Theme.MaterialComponents.*">
...
+ <item name="textAppearanceHeadline6">@style/TextAppearance.App.Headline6</item>
+ <item name="textAppearanceBody2">@style/TextAppearance.App.Body2</item>
</style>
+<style name="TextAppearance.App.Headline6"
+ parent="TextAppearance.MaterialComponents.Headline6">
@ricknout
ricknout / appcompat_mdc_type_update.xml.diff
Last active January 19, 2023 09:27
AppCompat to MDC-Android type update
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<com.google.android.material.card.MaterialCardView
...>
...
<TextView
android:id=”@+id/headerText”
- android:textAppearance="@style/TextAppearance.AppCompat.Title"
+ android:textAppearance="?attr/textAppearanceHeadline6"
... />
@ricknout
ricknout / appcompat_mdc_color_update.xml.diff
Created April 3, 2020 11:40
AppCompat to MDC-Android color update
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="Theme.App" parent="Theme.MaterialComponents.*">
...
<item name="colorPrimary">@color/navy_700</item>
- <item name="colorPrimaryDark">@color/navy_900</item>
+ <item name="colorPrimaryVariant">@color/navy_900</item>
- <item name="colorAccent">@color/green_300</item>
+ <item name="colorSecondary">@color/green_300</item>
+ <item name=”colorSecondaryVariant”>@color/green_500</item>
@ricknout
ricknout / appcompat_mdc_widgets_update.xml.diff
Created April 3, 2020 11:37
AppCompat to MDC-Android widgets update
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
-<androidx.cardview.widget.CardView
+<com.google.android.material.card.MaterialCardView
android:id="@+id/card"
...>
...
-</androidx.cardview.widget.CardView>
+</com.google.android.material.card.MaterialCardView>
@ricknout
ricknout / legacy_text_field_theme.xml.diff
Created April 3, 2020 11:34
Legacy text field in theme
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="Theme.App" parent="Theme.MaterialComponents.*">
...
+ <item name=”textInputStyle”>@style/Widget.App.TextInputLayout</item>
</style>
+<style name=”Widget.App.TextInputLayout” parent=”Widget.Design.TextInputLayout”>
+ <!-- Custom attrs -->
+</style>
@ricknout
ricknout / mdc_1.0.0_1.1.0_dependency_update.gradle.diff
Created April 3, 2020 10:59
MDC-Android 1.0.0 to 1.1.0 dependency update
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
-implementation ‘com.google.android.material:material:1.0.0’
+implementation ‘com.google.android.material:material:1.1.0’