Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Button] Outline of buttons in MaterialButtonToggleGroup are blurred #1422

Closed
mueller-ma opened this issue Jun 18, 2020 · 1 comment
Closed
Assignees

Comments

@mueller-ma
Copy link

Description:
I have a MaterialButtonToggleGroup with a three buttons, all with the outline style. The outlines on the outer buttons are blurred, while the outline of the button in middle isn't

Expected behavior:
Please see openhab/openhab-android#1615 (comment) for a photo of this issue. It seems that is happens only on low dpi devices.

Please see openhab/openhab-android#1615 (comment) for a possible explanation for this bug:

My guess would be rounding issues on hdpi devices, since that's the only density which yields a non-integer dp-to-px ratio (1.5 to be precise). This means e.g. 1dp becomes 1.5px, which can be displayed as 1px (too thin) or 2px (too wide).

Source code:
I can reproduce this issue with https://github.com/ricknout/android-mdc-theming, master at 576d0f2e02a599ccbc00b7bc2ee04709f962111a and the following diff:

diff --git a/app/src/main/res/values/styles_button.xml b/app/src/main/res/values/styles_button.xml
index a6ac8df..a52ccfe 100644
--- a/app/src/main/res/values/styles_button.xml
+++ b/app/src/main/res/values/styles_button.xml
@@ -22,10 +22,6 @@
         <item name="textAppearanceButton">@style/AppTextAppearance.Button</item>
         <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>
         <!-- Button widget style attributes -->
         <item name="materialButtonStyle">@style/AppButton2</item>
         <item name="materialButtonOutlinedStyle">@style/AppOutlinedButton</item>
diff --git a/build.gradle b/build.gradle
index 18bd726..9464d40 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
 buildscript {
-    ext.android_gradle_plugin_version = '4.0.0-rc01'
+    ext.android_gradle_plugin_version = '4.0.0'
     ext.kotlin_version = '1.3.72'
     ext.androidx_core_version = "1.3.0-rc01"
     ext.androidx_appcompat_version = "1.2.0-beta01"

Without the patch the outlines of all buttons are blurred.

Android API version:
At least on Android 5.1.1 and 7.1.2

Material Library version:
1.3.0-alpha01

Device:

@mueller-ma mueller-ma added the bug label Jun 18, 2020
@drchen drchen self-assigned this Oct 6, 2021
@drchen
Copy link
Contributor

drchen commented Apr 18, 2022

I think it's actually caused by RippleDrawable implementation of Lollipop doesn't correctly propagate drawable state when view is being attached (or under certain corner situations). So buttons in a toggle group look as in "disabled" state, and that's why the outlines are blurred.

Are you sure it also happen on Android 7? I can only reproduce this on Android 5/5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants