带有透明背景的按钮在Lollipop Android中变暗

时间:2015-08-18 09:54:51

标签: android android-view android-xml android-button nine-patch

我有一个带有透明部分的9patch背景的按钮,但整个按钮有这样的暗色效果:

darken button

这是按钮xml代码:

<Button
                    android:id="@+id/login_operator"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_margin="5dp"
                    android:background="@drawable/white_rounded"
                    android:drawableRight="@mipmap/arrow_white_down"
                    android:gravity="left|center_vertical"
                    android:text="@string/select_operator"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

以下是此按钮的外观:

enter image description here

这是9补丁背景图片:

enter image description here

这种变暗的效果只发生在Lollipop Android版本上..所以有谁知道这个变暗的效果来自哪里?

1 个答案:

答案 0 :(得分:3)

我用棒棒糖遇到了这个问题,由于某种原因,默认按钮样式有这种暗影效果

通过制作此自定义样式解决了这个问题:

<style name="ButtonStyle" parent="Widget.AppCompat.Button.Borderless">
    <item name="android:background">@drawable/trans</item>
</style>

将其分配给按钮:

<Button
       ....
       style="@style/ButtonStyle" />

这里有没有风格的外观:

enter image description here