Coder Social home page Coder Social logo

ricknout / android-mdc-theming Goto Github PK

View Code? Open in Web Editor NEW
436.0 16.0 83.0 343 KB

Sample code used for a series of Medium posts on Material Components for Android

Home Page: https://medium.com/@ricknout

Kotlin 83.26% Java 16.74%
android android-development material-design material-components material-theming

android-mdc-theming's Introduction

MDC Theming

Sample code used for a series of Medium posts on Material Components for Android

Intro: Setting up a Material Components theme for Android

https://medium.com/over-engineering/setting-up-a-material-components-theme-for-android-fbf7774da739

Part 1: Hands-on with Material Components for Android: Bottom App Bar

https://medium.com/over-engineering/hands-on-with-material-components-for-android-bottom-app-bar-28835a1feb82

Part 2: Hands-on with Material Components for Android: Bottom Navigation

https://medium.com/over-engineering/hands-on-with-material-components-for-android-bottom-navigation-aae2aa9066be

Part 3: Hands-on with Material Components for Android: Bottom Sheets

https://medium.com/over-engineering/hands-on-with-material-components-for-android-bottom-sheet-970c5f0f1840

Part 4: Hands-on with Material Components for Android: Buttons

https://medium.com/over-engineering/hands-on-with-material-components-for-android-buttons-76fa1a92ec0a

Part 5: Hands-on with Material Components for Android: Chips

https://medium.com/over-engineering/hands-on-with-material-components-for-android-chips-21dc67c8b956

Part 6: Hands-on with Material Components for Android: Cards

https://medium.com/over-engineering/hands-on-with-material-components-for-android-cards-311b00a5ea3

Part 7: Hands-on with Material Components for Android: Dialogs

https://medium.com/over-engineering/hands-on-with-material-components-for-android-dialogs-75c6d726f83a

Part 8: Hands-on with Material Components for Android: Selection Controls

https://medium.com/over-engineering/hands-on-with-material-components-for-android-selection-controls-a2cf17ea4473

More coming soon...

Playground

android-mdc-theming's People

Contributors

ricknout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-mdc-theming's Issues

round corners not working

Hello,

I tried to follow the tutorial as per the medium comment here . But still I'm not getting round corners. I made sure I extended the BottomSheetDialog thru my xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme.BottomSheet" parent="Theme.MaterialComponents.DayNight" />

    <style name="AppTheme.BottomSheet.Themed" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <!-- Global color attributes -->
        <item name="colorPrimary">@color/color_primary</item>
        <item name="colorPrimaryVariant">@color/color_primary_variant</item>
        <item name="colorOnPrimary">@color/color_on_primary</item>
        <item name="colorSecondary">@color/color_secondary</item>
        <item name="colorSecondaryVariant">@color/color_secondary_variant</item>
        <item name="colorOnSecondary">@color/color_on_secondary</item>
        <item name="colorError">@color/color_error</item>
        <item name="colorOnError">@color/color_on_error</item>
        <item name="colorSurface">@color/color_surface</item>
        <item name="colorOnSurface">@color/color_on_surface</item>
        <item name="android:colorBackground">@color/color_background</item>
        <item name="colorOnBackground">@color/color_on_background</item>
        <item name="android:statusBarColor">@color/color_status_bar</item>
        <!-- Global type attributes -->
        <item name="fontFamily">@font/roboto_mono</item>
        <item name="android:fontFamily">@font/roboto_mono</item>
        <!-- Global shape attributes -->
        <item name="shapeAppearanceSmallComponent">@style/AppShapeAppearance.SmallComponent</item>
        <item name="shapeAppearanceMediumComponent">@style/AppShapeAppearance.MediumComponent</item>
        <item name="shapeAppearanceLargeComponent">@style/AppShapeAppearance.LargeComponent</item>
        <!-- Bottom Sheet widget style attributes -->
        <item name="bottomSheetStyle">@style/AppStandardBottomSheet</item>
        <item name="bottomSheetDialogTheme">@style/AppModalBottomSheet</item>
    </style>

    <style name="AppStandardBottomSheet">
        <item name="shapeAppearance">?attr/shapeAppearanceLargeComponent</item>
        <item name="backgroundTint">?attr/colorSecondary</item>
        <item name="android:elevation">8dp</item>
        <item name="behavior_hideable">false</item>
        <item name="behavior_draggable">true</item>
        <item name="behavior_skipCollapsed">false</item>
        <item name="behavior_peekHeight">80dp</item>
        <item name="behavior_fitToContents">false</item>
        <item name="behavior_halfExpandedRatio">0.5</item>
        <item name="behavior_expandedOffset">0</item>
    </style>

    <style name="AppModalBottomSheet" parent="ThemeOverlay.MaterialComponents.DayNight.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/ModalBottomSheet</item>
    </style>

    <style name="ModalBottomSheet" parent="Widget.MaterialComponents.BottomSheet.Modal">
        <!-- Apply attributes here -->
    </style>
</resources>

But still, I'm not seeing the round corners

image

Question: is BottomSheetDialogFragment shown small on landscape, on purpose?

I've noticed that if you show the BottomSheetDialogFragment via the sample, by clicking on "show modal bottom sheet", while on landscape , it gets shown much smaller:

image

Is this on purpose?
Why does it occur?
Is there an official way to handle this? To know if it's in this state? Is it possible to expand it by default?

The only thing I've found about it, is a workaround as such:
https://stackoverflow.com/a/55713263/878126
but it's not an official solution...

Question: is it possible to use a theme based on OS settings?

On Android 8.1 (and maybe 9.0) there is a way to set a wallpaper or live wallpaper that will (try to) change the theme of the OS, making it dark or not.

Is it possible to adjust the UI based on it? If so, how can I do it and detect the theme?

I know that on Android Q it should be possible, but what about previous versions?

Can the chips have dynamic text other than "ChipDrawable"?

Hi,
Wonderful tutorial! The android documentation is particularly lacking and your project merges that gap.
In the file chip.xml the text seems hardcoded i.e. "ChipDrawable." Is this by design or can it be changed? I tried modifying chip.text but it made no difference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.