Challenge (help pls)

Does anybody find the solution?
I’ve tried this, but it made no effect.

<style name="BeatBoxButton" parent="Widget.AppCompat.Button">
        <item name="android:background">@drawable/button_beat_box</item>
        <item name="android:fadeEnabled">false</item>
        <item name="android:fadingEdge">none</item>
        <item name="android:fadeDuration">0</item>
        <item name="android:requiresFadingEdge">none</item>
</style>

Can I have some hint, @cstewart?

I don’t remember the exact solution, but i think you just want your parent to be the borderless button style:

widget.AppCompat.Button.Borderless

1 Like

What about overriding the stateListAnimator attribute for v21 styles and have it equal null? This seems to work for me. I used the below in my qualified styles file (v21) and it worked.

<style name="BeatBoxButton" parent="Widget.AppCompat.Button">
    <item name="android:background">@drawable/button_beat_box</item>
    <item name="android:stateListAnimator">@null</item>
</style>

I was able to find the below in one of the stackoverflow posts.

<!-- Bordered ink button -->
<style name="Widget.Material.Button">
    <item name="background">@drawable/btn_default_material</item>
    <item name="textAppearance">?attr/textAppearanceButton</item>
    <item name="minHeight">48dip</item>
    <item name="minWidth">88dip</item>
    <item name="stateListAnimator">@anim/button_state_list_anim_material</item>
    <item name="focusable">true</item>
    <item name="clickable">true</item>
    <item name="gravity">center_vertical|center_horizontal</item>
</style>

Since the effect happened when moving between states, I thought that the stateListAnimator was the reason for the shadow. I didn’t think about the background at all, which is the only overriding attribute in the borderless theme, as below:

<style name="Base.Widget.AppCompat.Button.Borderless">
    <item name="android:background">@drawable/abc_btn_borderless_material</item>
</style>

So, the borderless button casts no shadow, that makes sense.

Further, one more question, in my android studio, the cmd+click worked from my values file. It took me to
/Users/srinath/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/9d80826e172c056566f54527eea1c2de/res/values/values.xml

From there cmd+click didn’t actually work, I used the find tool to find the relevant themes and attributes. Any idea why this is happening?

FYI: I do use org.gradle.caching=true in my gradle properties.

For me, using Widget.AppCompat.ImageButton as a parent was enough to have nice buttons without a border or extra shading.

<style name="BeatBoxButton" parent="Widget.AppCompat.ImageButton">
    <item name="android:background">@drawable/button_beat_box</item>
</style>

@Srinath cmd+click takes you to the point where the class/style/attribute/component you are clicking has been defined.

The reason it’s not working I believe is probably because you are trying to apply cmd+click to an actual value being passed to an attribute.

For example if I cmd+click on Widget.AppCompat.Button.Borderless (BeatBoxButton’s parent); that sends me to values.xml specifically to the line where Widget.AppCompat.Button.Borderless is defined.

At which point if I cmd+click Base.Widget.AppCompat.Button.Borderless (Widget.AppCompat.Button.Borderless’ parent ). That sends me to the line where Base.Widget.AppCompat.Button.Borderless is defined. Note it is in the same file.

There if I attempt to cmd+click abc_btn_borderless_material the value passed in for the android:background attribute nothing happens.

Watch this quick video of how I traverse the theme hierarchy using cmd+click.