9Patch on Lollipop shows gray oval in background

坚强是说给别人听的谎言 提交于 2019-12-06 10:18:51

问题


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

Lollipop Screenshot:

KitKat Screenshot:

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.


回答1:


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.



来源:https://stackoverflow.com/questions/28737164/9patch-on-lollipop-shows-gray-oval-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!