There is a task, when you click the button, show the shadow

I do this:

<Button android:layout_width="@dimen/button_width" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_action_message" android:background="@drawable/home_button_background_selector" android:paddingStart="15dp"/> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/home_button_press_background" android:state_selected="true"></item> <item android:drawable="@drawable/home_button_press_background" android:state_pressed="true"></item> <item android:drawable="@drawable/home_button_background"></item> </selector> <item name="android:buttonStyle">@style/MyCustomButton</item> <style name="MyCustomButton" parent="Widget.AppCompat.Button.Borderless"> <item name="android:minHeight">0dp</item> <item name="android:minWidth">0dp</item> <item name="android:layout_height">100dp</item> <item name="android:background">?attr/selectableItemBackground</item> </style> 

Button background (normal) - png 326x60px enter image description here

button background when pressed - png 326x67px enter image description here

The problem is that when you click on a button, the button does not expand along the height of the background image, but simply stomps the background image. those. the physical size of the button remains the same, and the background picture narrows up (the blue line rises up to the text) I obviously do something wrong :), tell me, please.

Shl. Black flooded to see better. purple is our shadow

  • 2
    Well, add 7 pixels of the black top picture - Yura Ivanov
  • one
    when you click on the button, increase its size to the size of the shadow - boneferz
  • Thank. I try the first option. I did not guess: D. - DuosDuo

0