I'm new in Android app developing and I realized that, at the end of the day, what truly matters to the end user is the App's UI.
I always try to do my best when it comes to UI's, but I always end up having some troubles. In particular, one of the main problems I always have and I don't know how to fix, is that when I set a custom background color or image to some button, the click effect disappears. So you click the button and although it obviously works, it's pretty unpleasant to see how it does nothing graphically.
I'd like to know if there's some way to get the original effect back, or set some click effect myself programmatically.
Thanks in advance.
Save this as a drawable and set as the background:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#212121"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#424242"/>
<corners android:radius="5dp"/>
</shape>
</item>
</selector>
This is just a simple example. You can create more complicated ones yourself.
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