Custom button: change style when pressed

I created a button with a shadow using the style:

<style name="test">
  <item name="android:shadowColor">#FFFFFF</item>
  <item name="android:shadowRadius">1</item>
  <item name="android:shadowDx">1</item>
  <item name="android:shadowDy">1</item>
</style>

This will apply a white shadow to the button text in the normal state. I'm just wondering if anyone knows if there is a way to remove this shadow when the button is pressed. In other words, is there a way to apply a different style when the button is in a different (pressed) state?

Thanks in advance!

change

bold.xml:

<resources>
    <style name="bold_text">
        <item name="android:textStyle">bold</item>
    </style>
</resources>

button.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/test_pressed"
              style="@style/bold_text"
          android:state_pressed="true"/>
    <item android:drawable="@drawable/test_focused"
          android:state_focused="true"/>
    <item android:drawable="@drawable/test_normal"/>
</selector>

my layout:

<Button
        ...
        android:background="@drawable/button"/>
+5
source share
2 answers

button.xml, , ( ..) , drawable. .

button2.xml. , , "drawable" "state_ *". "textColor", XML, ( = ".." ) . !

Schwiz ... , "color" : . ColorStateList.

0

All Articles