0

I have the following layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <androidx.camera.view.PreviewView
        android:id="@+id/viewFinder"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />


    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_image_select"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_margin="20dp"
        app:icon="@drawable/baseline_photo_24"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        style="@style/MaterialIconButtonCircledDarkTransparentStyle"
        />


    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_image_capture"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:layout_margin="20dp"
        app:strokeWidth="2dp"
        app:strokeColor="@color/white"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        style="@style/MaterialIconButtonCircledLightTransparentStyle"
        />


</androidx.constraintlayout.widget.ConstraintLayout>

With the following style:

<style name="MaterialIconButtonCircledDarkTransparentStyle">
    <item name="android:insetLeft">0dp</item>
    <item name="android:insetTop">0dp</item>
    <item name="android:insetRight">0dp</item>
    <item name="android:insetBottom">0dp</item>
    <item name="iconPadding">0dp</item>
    <item name="iconGravity">textStart</item>

    <item name="background">@color/BlackTransparent</item>
    <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlayMaterialIconButtonCircular</item>
</style>


<style name="MaterialIconButtonCircledLightTransparentStyle" parent="MaterialIconButtonCircledDarkTransparentStyle">
    <item name="android:backgroundTint">@color/LightGrayTransparent</item>
</style>

<style name="ShapeAppearanceOverlayMaterialIconButtonCircular" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">50%</item>
</style>

<color name="LightGrayTransparent">#80C0C0C0</color>
<color name="BlackTransparent">#6A000000</color>

Which looks like this:

example

As you can see there is a random pentagon shaped style which is visible when I have a transparent backgroundTint. Any idea how I can hide the pentagon shaped form? I tried setting the ripple color to null and other options, but none of them worked unfourtantly.

Funny Moments
  • 421
  • 2
  • 13
  • 1
    That's Android's material shadow artifact. It's usually hidden 'cause most `View`s have opaque backgrounds. If you don't need the elevation shadow on the `Button`s, you can simply set `android:stateListAnimator="@null"`. If you do need the shadow, just without the artifact, that'll take some sort of workaround, AFAIK. – Mike M. Jan 08 '23 at 19:57
  • @MikeM. thank you! it works, feel free to post it as a answer so I can accept it :) – Funny Moments Jan 08 '23 at 20:00
  • 1
    No problem! I should've also mentioned that on most other `View`s, you'd want to set `android:elevation="0dp"` instead. The `stateListAnimator` attribute usually only applies to `Button`s. Anyhoo, thanks for the offer, but I'm too lazy to post answers atm. :-) Please feel free to finish this up however you like. Glad I could help. Cheers! – Mike M. Jan 08 '23 at 20:09

0 Answers0