Skip to content

[DynamicColors] Generated Colors are not precise #4996

@Yamenher

Description

@Yamenher

Description: passing a seed color in DynamicColorsOptions.Builder has some colors that are not precise compared to regular DynamicColors

Expected behavior: Notice the switch icon tint and the FAB colors

Image Image

now here's the outcome with a custom seed color, focus on the switch icon color on checked state and the FAB color

Image Image

Source code:

DynamicColorsOptions.Builder options = new DynamicColorsOptions.Builder();
options.setContentBasedSource([color int here]);
DynamicColors.applyToActivityIfAvailable(this, options.build());

Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.

Main Layout

<androidx.coordinatorlayout.widget.CoordinatorLayout

    xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@null"
    android:orientation="vertical">
<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/FAB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/ic_shuffle" 
        style="@style/Widget.Material3.FloatingActionButton.Small.Primary"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
package com.example.app

public class MainActivity extends AppCompatActivity{

 @Override

	protected void onCreate(Bundle bundle) {
DynamicColorsOptions.Builder options = new DynamicColorsOptions.Builder();
                    options.setContentBasedSource(0xffff0000);                   DynamicColors.applyToActivityIfAvailable(this, options.build()); 
}
}

Android API version: SDK 36

Material Library version: v1.13.0 (stable)

Device: Redmi Note 13 Pro 5G, AOSP based Custom ROM

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions