【问题标题】:Android button with transparent text带有透明文本的 Android 按钮
【发布时间】:2015-02-20 18:12:44
【问题描述】:

我在图片上有一个按钮。我希望此按钮具有纯色背景色和透明文本(以显示背面图像)。是否可以让它只有透明文本?

【问题讨论】:

    标签: java android android-button android-shape


    【解决方案1】:

    尝试将这些属性添加到您的 Button:

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

    【讨论】:

      【解决方案2】:

      透明是指部分可见。还要查看图像按钮,而不是将背景图像分配给按钮。

      【讨论】:

      • 我不认为 ImageButton 是他们想要的。按照他们的描述,他们希望按钮只覆盖图像的部分,并且按钮上的文本是透明的,以便可以看到其后面的图像。
      【解决方案3】:

      这听起来像是 ImageButton 的一个用例。它允许指定图像和背景。注意 src 和 background 标签,txt 不是必需的。

      <ImageButton
          android:id="@+id/imageBtn"
          android:layout_width="@dimen/btn_large_len"
          android:layout_height="@dimen/btn_large_len"
          android:src="@drawable/ic_action_play"
          android:background="@drawable/btn_gray" >
      </ImageButton>
      

      【讨论】:

        猜你喜欢
        • 2020-12-14
        • 2015-11-19
        • 1970-01-01
        • 2014-07-16
        • 1970-01-01
        • 2021-09-18
        • 2011-09-15
        • 1970-01-01
        • 2013-01-13
        相关资源
        最近更新 更多