3

I have the following button:

<Button
    android:layout_height="32dp"
    android:layout_marginTop="4dp"
    android:layout_marginLeft="@dimen/aecs_item_inner_padding_positive"
    android:id="@+id/aecsTelephone"
    android:layout_width="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_below="@id/aecsServicesContainer"
    android:layout_alignParentLeft="true"
    android:text="Mobile"
    android:background="@drawable/selector_mobile_button" />

and it has the following background selector:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/mobile_btn_pressed" android:state_pressed="true"></item>
    <item android:drawable="@drawable/mobile_btn"></item>
</selector>

on Lollipop only the background shows an oval gray layer and I don't have any clue from where this layer is shown?

Note that using the none 9-patch version of the image fixes the problem, but I don't know why!

mobile_btn.9.png

enter image description here

Lollipop Screenshot: enter image description here

KitKat Screenshot: enter image description here

Edit: The problem is solved. Okay..It was in the transparency of the 9-patch image, I used it from the hdpi folder and when it gets scaled the transparency area gets corrupted. However I am still shocked why on earth the problem shows up on Lollipop only. After I used the image as it is without any scale the problem is fixed.

user2864740
  • 60,010
  • 15
  • 145
  • 220
Mahdi Hijazi
  • 4,424
  • 3
  • 24
  • 29
  • Do you mean on `Lollipop` device or targetSDK? – Xcihnegn Feb 26 '15 at 09:06
  • The device, the first one is on Nexus 4 with Lollipop and other one is on S5 with KitKat, the target sdk is always 21. – Mahdi Hijazi Feb 26 '15 at 09:11
  • 1
    For device, so you can refer to this post [Lollipop RippleDrawable vs Selector for Pre-Lollipop](http://stackoverflow.com/questions/24607339/lollipop-rippledrawable-vs-selector-for-pre-lollipop) – Xcihnegn Feb 26 '15 at 09:28
  • @Xingchen I tried to encapsulate my 9patch inside the ripple xml but that didn't work as well. Please note that if I disable the 9patch and use normal image the problem is gone without using the ripple. – Mahdi Hijazi Feb 26 '15 at 13:40
  • How about setting android:paddingMode=1 for the LayerDrawable? – Vrashabh Irde Feb 26 '15 at 15:01
  • 1
    Okay..The problem was in the transparency of the 9-patch image, I used it from the hdpi folder and when it gets scaled the transparency area gets corrupted. However I am still shocked why on earth the problem shows up on Lollipop only. After I used the image as it is without any scale the problem is fixed. – Mahdi Hijazi Mar 01 '15 at 08:49
  • @MahdiHijazi what do you mean by `The problem was in the transparency of the 9-patch image`? – Muhammad Babar Jan 22 '16 at 06:12

1 Answers1

0

Use TextView and set android:focusable="true" if you don't need the default Button styling. The Button widget is just a tiny set of properties on top of TextView and includes default elevation and z-depth animation.

alanv
  • 23,966
  • 4
  • 93
  • 80