I created button with some shadow using a 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 applies a white shadow on the button's text in its normal state. I was just wondering if anyone knows if there is a way to remove this shadow when the button is a pressed state. In other words, is there a way to apply another style when the button is in another (pressed) state?
Thanks in advance!
edit
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"/>
Unfortunately, there is no :click pseudo selector. If you want to change styling on click, you should use Jquery/Javascript. It certainly is better than the "hack" for pure HTML / CSS.
:active denotes the interaction state (so for a button will be applied during press), :focus may be a better choice here. However, the styling will be lost once another element gains focus.
To change button style on press in React Native, we can wrap our button with the TouchableHighlight component. to define the touchProps object that we use to set the props of TouchableHighlight . We set onHideUnderlay to a function that runs when the underlay is hidden.
You want a ColorStateList http://developer.android.com/guide/topics/resources/color-list-resource.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With