【问题标题】:Remove shadow effect on android button删除android按钮上的阴影效果
【发布时间】:2015-03-08 04:05:56
【问题描述】:

我在布局中添加了一个简单的按钮,并删除了文本并设置了一个透明的图像作为其背景。但不幸的是,我的按钮上有阴影效果,我无法删除它。如果您对此有任何帮助,我将不胜感激。
谢谢!

【问题讨论】:

  • 更改为imagebutton并像这样放置背景:android:background="@android:color/transparent
  • 非常感谢,是的,这就是问题所在,您能否将其添加为答案,以便我选择它。谢谢

标签: android layout styles themes


【解决方案1】:

您的 xml ,而不是您拥有的按钮,应该是这样的:

    <ImageButton android:src="@drawable/yourimagename"
     android:id="@+id/button1"
     android:layout_width = "wrap_content"
     android:layout_height = "wrap_content"
     android:background="@null"
     />

如果您有任何问题,请告诉我;)

【讨论】:

【解决方案2】:

关于按钮标签集

android:stateListAnimator="@null"

示例:

<Button
        android:id="@+id/button1"
        android:layout_height="50dp"
        android:layout_width="match_parent"
        android:stateListAnimator="@null"/>

【讨论】:

  • 这是一个很好的解决方案,但它需要 API 级别 21。是否有适用于较低 API 级别的解决方案?
  • @Barnaby 我猜是在 Lollipop 上添加了“阴影”效果,因此默认情况下较低的 API 级别不会显示任何阴影。谁能证实这一点?
猜你喜欢
  • 2022-01-21
  • 2015-04-29
  • 1970-01-01
  • 2015-04-28
  • 1970-01-01
  • 1970-01-01
  • 2016-11-23
  • 2022-01-01
  • 2012-02-04
相关资源
最近更新 更多