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

[MaterialShapeDrawable] Unable to add gradient to MaterialShapeDrawable #1167

Open
railianmaksym opened this issue Mar 30, 2020 · 9 comments

Comments

@railianmaksym
Copy link

Is your feature request related to a problem? Please describe.
A have a lot of cases when I need to use a gradient with material shapes, but I can't do it because
MaterialShapeDrawable used the only fillColor.
If I want to use gradient or another drawable view with MaterialShapeDrawable becomes black.

Describe the solution you'd like
Add the possibility to use drawables with MaterialShapeDrawable.

@wcshi
Copy link
Contributor

wcshi commented Mar 31, 2020

"A have a lot of cases when I need to use a gradient with material shapes", could you please explain what they are?

@vitorhugods
Copy link

vitorhugods commented Apr 30, 2020

Simple widgets with gradient background, like this:

Floating Action Button:
grafik

Chip:
grafik

Button:
grafik

@Shusshu
Copy link

Shusshu commented Sep 11, 2020

Would be great if FloatingActionButton supported custom backgrounds like MaterialButton and ExtendedFloatingButton (which extends MaterialButton)

@TurKurT656
Copy link

TurKurT656 commented Nov 27, 2020

FloatingActionButton does not supports custom backgrounds. (for example gradient background)
It would be great if we have this functionality

@Shusshu
Copy link

Shusshu commented Nov 27, 2020

I found a workaround to get it with not too much work
Use ExtendedFloatingActionButton without label (shrinked) and override the background (as it's a MaterialButton you can just do it)

@TurKurT656
Copy link

I found a workaround to get it with not too much work
Use ExtendedFloatingActionButton without label (shrinked) and override the background (as it's a MaterialButton you can just do it)

can you add a link or sample code?

@Shusshu
Copy link

Shusshu commented Nov 28, 2020

    extendedFab.backgroundTintList = null
    extendedFab.setBackgroundResource(R.drawable.btn_extendedfab_shrinked_gradient)

R.drawable.btn_extendedfab_shrinked_gradient

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/btn_shape_extendedfab_shrinked_disabled" android:state_enabled="false" />

    <item android:state_enabled="true">
        <ripple android:color="?attr/colorControlHighlight">
            <item android:drawable="@drawable/btn_shape_extendedfab_shrinked_gradient" />
        </ripple>
    </item>
</selector>

btn_shape_extendedfab_shrinked_gradient

    <?xml version="1.0" encoding="utf-8"?>
    <inset xmlns:android="http://schemas.android.com/apk/res/android">
      <shape android:shape="rectangle">
        <corners android:radius="56dp" />
        <gradient
                android:angle="90"
                android:endColor="#000000"
                android:startColor="#ffffff"
                android:type="linear" />
        <padding android:left="0dp"
                android:top="0dp"
                android:right="0dp"
                android:bottom="0dp" />
      </shape>
    </inset>

@sanisloandras
Copy link

Still waiting for this... Have to use AppCompatButton to implement simple button with gradient background...

@wiryadev
Copy link

still waiting

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

9 participants