【问题标题】:How to remove the square border from a image button如何从图像按钮中删除方形边框
【发布时间】:2016-02-04 22:20:35
【问题描述】:

我有一个像“星”一样的图像按钮形状,我的可点击区域只是“星”,但我在“星”周围有一个透明的方形可点击区域,谁能告诉我怎么做要删除正方形 bcoz 下一个“星星”,它很接近并且正方形与第一个“星星”重叠。 非常感谢

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical"
    android:layout_weight="1"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="190dp"
    android:layout_marginBottom="180dp">

    <ImageButton
        android:id="@+id/star"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@drawable/star"
        />

【问题讨论】:

标签: android imagebutton


【解决方案1】:

您可以使用 ImageView 代替 ImageButton 并进行 clicable。

【讨论】:

  • 也这样做了,但我仍然可以在广场上单击,星星会开始,我正在寻找一些东西来呈现星星的形状并且可以点击。谢谢大家的快速解答
【解决方案2】:

设置

android:background=@android:color/transparent

并插入

android:src=@drawable/star

或者只使用 ImageView 代替,因为您可以在两者上都有 OnClickListener,因此它们也可以按照您的问题中描述的方式运行。

【讨论】:

  • 已经完成此操作,并且仍然可以从按钮单击距离正方形中星星 2dp 的位置
【解决方案3】:

你可以使用:

android:background="@null"

imageButton 标签中。

【讨论】:

    猜你喜欢
    • 2015-12-16
    • 2022-11-26
    • 2017-10-12
    • 2012-07-14
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多