【问题标题】:Android, remove custom button borderAndroid,移除自定义按钮边框
【发布时间】:2010-09-27 11:02:11
【问题描述】:

我将此选择器代码用于我的自定义按钮 (simple.xml)

  <?xml version="1.0" encoding="utf-8"?>

  <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/focused" />
      <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" />
      <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" />
      <item android:drawable="@drawable/defaultbutton" />
  </selector>

但在我的 ImageButton 上,我不知道如何删除边框。我只想显示我的图像而不显示按钮周围的边框。

谢谢

【问题讨论】:

    标签: android background imagebutton


    【解决方案1】:

    我替换

        <ImageButton android:id="@+id/imagebutton"
      android:src="@drawable/simple"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      />
    

    与:

        <ImageButton android:id="@+id/imagebutton"
      android:background="@drawable/simple"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      />
    

    然后工作

    【讨论】:

      【解决方案2】:

      设置android:background 而不是android:drawable

      【讨论】:

      • 我将 android:drawable="@drawable/focused" 替换为 android:background="@drawable/focused" ,但出现强制关闭错误。谢谢
      • 在我使用的 xlm 文件中:
      猜你喜欢
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多