-2

I have a image button which is designed like this

 <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/plusOneButton"
            android:layout_marginBottom="5dp"
            android:src="@drawable/thinking"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:background="@drawable/button_border"
            />

The button_border xml looks like this.

  <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <stroke
        android:width="30dp"
        android:color="#ff000000" />
    <padding
        android:left="1dp"
        android:top="1dp"
        android:right="1dp"
        android:bottom="1dp" />

</shape>

There fore the image is enclosed by a box, It doesn't look like a pressable button. How do i add shadows to it to make it look like a button? Kindly help, I am new to android. I don't want to add ripple as the minimum api level in my app is 14.

55597
  • 2,033
  • 1
  • 21
  • 40
  • you need to describe better the desired effect (possibly with some images) – Bartek Lipinski Jul 31 '15 at 15:21
  • I think that there's some confusion here, how "ripple" is related to "shadow". Ripple is the material equivalent of selector.. – Giorgio Antonioli Jul 31 '15 at 15:23
  • My mistake in adding about ripple, As you pointed out, I dont want a selector, I need a shadow that makes my image button to look like its a clickable button – 55597 Jul 31 '15 at 15:26

1 Answers1

0

You can use the Layer-List which give you the ability to add two or more shapes in order to achieve the shadow then you need to create a selector drawable to set what are the drawable to use in each state like focus , pressed ... etc these links will help you check them :

layer-list

http://nick.perfectedz.com/android-layerlist-tip/

Selector

http://www.compiletimeerror.com/2014/03/android-button-selector-tutorial-with.html

i hope this will help you :)

Community
  • 1
  • 1
Mohammad Salem
  • 1,113
  • 9
  • 15