问题
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