【问题标题】:Remove Extra Space between Views删除视图之间的额外空间
【发布时间】:2020-10-16 06:42:43
【问题描述】:

我正在构建一个简单的计算器应用程序,但我无法摆脱 ImageButton 旁边的额外灰线

按钮代码

<Button
  android:id="@+id/button_clear"
  android:layout_width="0dp"
  android:layout_height="match_parent"
  android:layout_weight="1"
  android:background="@color/white"
  android:text="AC"
  android:textColor="@color/indigo"
  android:textSize="18sp" />

图像按钮代码

<ImageButton
  android:id="@+id/button_back"
  android:layout_width="0dp"
  android:layout_height="match_parent"
  android:layout_weight="1"
  android:src="@drawable/backspace"
  android:background="@color/white"/>

如您所见,按钮非常完美,但 ImageButton 旁边有灰线。 我尝试将父背景设置为“白色”并将 ImageButton 背景设置为“@null” 我尝试了 Imageview,但问题仍然存在 我尝试将图像设置为按钮的背景,它仍然存在 我什至尝试向左右设置负边距,但问题仍然存在

有人可以帮帮我吗?

【问题讨论】:

  • 你能分享这个布局的完整 xml 吗?

标签: java android xml image button


【解决方案1】:

我有一个建议:使用按钮显示⌫符号。有关如何获得所需结果的信息,请访问:How to make ⌫ symbol backward-compatible in Android Studio?

【讨论】:

    【解决方案2】:

    在你的 ImageButtons 中添加这个

    style="?android:attr/borderlessButtonStyle"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-28
      • 2013-01-09
      • 2017-08-08
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-21
      相关资源
      最近更新 更多