Android:按钮应为透明时褪为灰色

时间:2019-07-03 23:57:49

标签: android android-layout

我想要一个具有完全透明背景的基本按钮(因此,唯一可见的是文本。)

根据其他答案,我设置了android:background="#0000",但它仍然具有褪色的灰色。

这是完整的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#3176C0">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#0000"
        android:text="TRANSPARENT?" />

</RelativeLayout>

它是什么样的:

enter image description here

我想要什么:

enter image description here

4 个答案:

答案 0 :(得分:2)

事实证明,它不是背景显示,而是默认按钮样式的阴影。

因此,答案是需要通过将按钮样式添加到按钮来更改按钮样式:

style="?android:attr/borderlessButtonStyle"

答案 1 :(得分:1)

尝试此代码...

{
    "date": "05/30/2019",
    "name": "JOSH",
    "discount": "160.00"
}, {
    "date": "04/30/2019",
    "name": "JOSH",
    "discount": "170.00"
}, {
    "date": "03/30/2019",
    "name": "JOSH",
    "discount": "79.00"
}

答案 2 :(得分:1)

答案 3 :(得分:0)

尝试一下:

android:background="@android:color/transparent"