【问题标题】:Android - Another button questionAndroid - 另一个按钮问题
【发布时间】:2010-08-22 15:43:11
【问题描述】:

这是一个愚蠢的问题。做好准备。

我的 main.xml 是这样的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent"
 android:background="@android:color/white">
 <ImageButton
 android:src="@drawable/button"
 android:scaleType="fitStart"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
 /> 
</RelativeLayout>

它有效。但是,我实际上看到了一个带有我的图像的 android 按钮。当你点击它时,外面变成橙色和一切。如何获取它以使外部按钮不出现?

请帮忙?

【问题讨论】:

    标签: android eclipse image button scale


    【解决方案1】:

    有两种可能的处理方式:

    1. 为按钮设置透明背景。
    2. 使用 ImageView 而不是 Button(您可能需要设置 android:focusable="true" 以使其可聚焦)

    【讨论】:

    【解决方案2】:

    如果您实际上并不想要一个按钮(并且按钮看起来确实如您所描述的那样),您希望向 ImageView 添加一个 onClick 侦听器。

    【讨论】:

    • 好吧,我没有意识到可以在 XML 中指定 On Click 操作(很高兴知道)。看起来 ImageView 也有这个属性,所以你应该也可以在那里设置它。
    猜你喜欢
    • 1970-01-01
    • 2017-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 1970-01-01
    相关资源
    最近更新 更多