All Projects → DeweyReed → Theme

DeweyReed / Theme

Licence: Apache-2.0 license
🎨 An Experimental Theme Engine for Android

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Theme

GitReposCompose
GitReposCompose is an Android application 📱 for showcasing Jetpack Compose for building declarative UI in Android. This demo app uses Github public API for fetching public repositories.
Stars: ✭ 32 (-64.04%)
Mutual labels:  android-ui
SwipeToReply
Swipe to reply UI like WhatsApp
Stars: ✭ 54 (-39.33%)
Mutual labels:  android-ui
FlowingPager
A Flexible Side Sliding View Controlled by a Button
Stars: ✭ 104 (+16.85%)
Mutual labels:  android-ui
Whatsapp Android App
This is sample code for layout for chatting app like Whatsapp.
Stars: ✭ 32 (-64.04%)
Mutual labels:  android-ui
momentz
Momentz is an android library for showing timed view just like WhatsApp, Facebook and Instagram stories.
Stars: ✭ 107 (+20.22%)
Mutual labels:  android-ui
ZoomLayout
想要缩放、平移的 View,放在 ZoomLayout 中就可以实现了
Stars: ✭ 34 (-61.8%)
Mutual labels:  android-ui
QuadTreeAndroid
Library that helps to implement the QuadTree in android, by using splitting images
Stars: ✭ 30 (-66.29%)
Mutual labels:  android-ui
PaymentCardView
Custom Credit/Debit card view
Stars: ✭ 62 (-30.34%)
Mutual labels:  android-ui
Biometric-Authentication-Android
A sample implementation of AndroidX biometrics API using Kotlin. Authenticate using biometrics or PIN/Password if biometrics isn't available on device. Fully implemented in Jetpack compose using Material 3 dynamic theming and also has a separate implementation in xml with MDC 3.
Stars: ✭ 29 (-67.42%)
Mutual labels:  android-ui
FancyBottomSheetDialog
This is android library implementing bottom sheet like fancy dialog
Stars: ✭ 21 (-76.4%)
Mutual labels:  android-ui
MaterialDesign-Toast
Custom android Toast with Material Design
Stars: ✭ 70 (-21.35%)
Mutual labels:  android-ui
floating-layout-android
Floating Layout library for Android
Stars: ✭ 55 (-38.2%)
Mutual labels:  android-ui
Einsen
🎯 Einsen is a prioritization app that uses Eisenhower matrix technique as workflow to prioritize a list of tasks & built to Demonstrate use of Jetpack Compose with Modern Android Architecture Components & MVVM Architecture.
Stars: ✭ 821 (+822.47%)
Mutual labels:  android-ui
OnboardingDemo
Onboarding Example. Uses ViewPager's PageTransformer to animate elements.
Stars: ✭ 44 (-50.56%)
Mutual labels:  android-ui
ui-testing
No description or website provided.
Stars: ✭ 15 (-83.15%)
Mutual labels:  android-ui
ReactButton
Android Library to make it easy to add ReactButton feature in your app with Multi Reactions like Facebook or Linkedin, you can add many reactions as you want, you can also split them into a number of columns, and also customize the colours and text for each reaction
Stars: ✭ 100 (+12.36%)
Mutual labels:  android-ui
LicenseTextView
Custom Lincese TextView for android
Stars: ✭ 31 (-65.17%)
Mutual labels:  android-ui
recyclerfragment
An Android Fragment that displays a set of items in a RecyclerView.
Stars: ✭ 16 (-82.02%)
Mutual labels:  android-ui
CoolAnimation4Beginner
Making Beauty Android UI/UX Design with cool Animation
Stars: ✭ 21 (-76.4%)
Mutual labels:  android-ui
spokestack-tray-android
A UI component that makes it easy to add voice interaction to your app.
Stars: ✭ 13 (-85.39%)
Mutual labels:  android-ui

[Experimental] Theme

Android CI API Releases

image

Theme is an experimental theme engine for Android by retinting views after their creation.

This library is inspired by aesthetic and Cyanea.

WARNING

  • Theme is a companion of material-components-android, so it requires you to adopt material-components-android in your project.
  • Currently, Theme supports material-components-android 1.1.0, 1.2.x, 1.3.0 and 1.4.0. Any other version doesn't work.
  • Because the implementation is fragile, think twice, and do some investigation before using this library.
  • Jetpack Compose supports theming programmatically and is a better alternative(in the future).

Sample App

Sample APK from Release.

Usage

  1. Install dependency:

    1. Add the JitPack repository to your build file

      allprojects {
          repositories {
              ...
              maven { url 'https://jitpack.io' }
          }
      }
    2. Add the dependency

      Releases

      dependencies {  
          implementation 'xyz.aprildown:Theme:0.4.0' // for material-components-android 1.4.0
          // implementation 'xyz.aprildown:Theme:0.3.1' // for material-components-android 1.3.0
          // implementation 'xyz.aprildown:Theme:0.2.0' // for material-components-android 1.2.x
          // implementation 'xyz.aprildown:Theme:0.1.4' // for material-components-android 1.1.0
      }
  2. Define six theme colors:

    <resources>
        <color name="colorPrimary">#008577</color>
        <color name="colorPrimaryVariant">#00574B</color>
        <color name="colorOnPrimary">#FFFFFF</color>
        <color name="colorSecondary">#D81B60</color>
        <color name="colorSecondaryVariant">#A00037</color>
        <color name="colorOnSecondary">#FFFFFF</color>
    </resources>
    • The color resources name must be identical to the names above.
    • Color values must be formatted as #RRGGBB. Color references won't work because of how TypedArray.getResourceId works.
  3. Add an attribute to your root theme:

    <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        ...
        <!-- Add this line -->
        <item name="viewInflaterClass">xyz.aprildown.theme.ThemeViewInflater</item>
    </style>
  4. In your Application:

    Theme.init(
        context = this,
        themeRes = R.style.AppTheme
    ) {
        // Optional. Provide initial colors here.
        // The usage is same as the code below.
    }
  5. Change colors:

    Theme.edit(this) {
        colorPrimaryRes = R.color.md_amber_500
        colorPrimaryVariantRes = R.color.md_amber_800
        colorOnPrimary = on(colorPrimary)
        colorSecondaryRes = R.color.md_blue_500
        colorSecondaryVariantRes = R.color.md_blue_800
        colorOnSecondary = on(colorSecondary)
        colorStatusBar = colorPrimaryVariant
    }
    • Variables ending with Res expect a ColorRes. Other variables expect a ColorInt.
    • After editing, you have to recreate activities in the back stack manually.
  6. [Optional] Use colors at runtime.

    Theme.get().colorPrimary

More Settings

Tint Status Bar and Navigation Bar

Theme.tintSystemUi(activity)
  • Put it in activity's onCreate, but if you're using DrawerLayout, put it after DrawerLayout is inflated(usually it's after setContentView).

Disable Theme

This's useful when you show a MaterialDatePicker because Theme messes up its colors.

button.setOnClickListener {
    Theme.get().enabled = false
    MaterialDatePicker.Builder.datePicker()
        .build()
        .apply {
            addOnDismissListener {
                Theme.get().enabled = true
            }
        }
        .show(childFragmentManager, null)
}

Support Custom Views

  1. Create a ThemeInflationDelegate like AppComponentsDelegate.

  2. Add it after Theme's initialization:

    Theme.init(...)
    Theme.installDelegates(AppComponentsDelegate())

Limitation

  • Style Toolbar according to the docs, or the tint doesn't work.
  • Theme doesn't use any reflection, so it's hard to tint widgets like TimePicker.

How Theme Works

material-components-android makes setting attributes programmatically very easy. ThemeViewInflater extends MaterialComponentsViewInflater and does all retint work. Classes named ***Tint resolves color attributes from AttributeSet and applies new color.

License

Apache License 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].