2

I just noticed that the borders of the Button and the ImageButton look different. The ImageButton is totally flat. I cannot explain it and I would like to have the ImageButton as "3d-ish" as the default Button. Any ideas are welcome!

This is my xml-code

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Power"
        android:id="@+id/button1"
        android:layout_gravity="center"
        android:layout_weight="0"
        android:layout_centerInParent="true" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/f_light_on"
        android:id="@+id/button4"
        android:layout_gravity="center"
        android:layout_weight="0"
        android:layout_centerInParent="true" />
</LinearLayout>

And this is how it looks on my Lollipop tablet: enter image description here

Thanks in advance! Thomas

Dark.Rider
  • 372
  • 1
  • 4
  • 16

1 Answers1

3

Button has default elevation (actually, it has a StateListAnimator that provides elevation when the button is enabled) under the Material theme, whereas ImageButton does not.

alanv
  • 22,812
  • 4
  • 87
  • 77
  • thank you! this clarifies the behavior, although it doesn't seem consistent. – Dark.Rider Nov 13 '15 at 19:20
  • `ImageButton` is often used with a null background, which doesn't lend itself to setting an elevation. We opted for breaking as few apps as possible when designing the Material widget styles. – alanv Nov 13 '15 at 20:04