【问题标题】:Android - Image button (XML) isn't working?Android - 图片按钮 (XML) 不起作用?
【发布时间】:2010-08-20 19:51:57
【问题描述】:

我的可绘制文件夹中有三张图片,以及一个 XML 图片按钮代码:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">\
<item android:state_pressed="true"
android:drawable="@drawable/happycarrot" /> <!-- pressed -->
<item android:state_focused="true" 
android:drawable="@drawable/largerunicornbutton2" /> <!-- focused -->
<item android:drawable="@drawable/largerunicornbutton" /> <!-- default -->
</selector>

在我的布局文件夹中,我有我的主要 XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:src="@drawable/button"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
></ImageView>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello"
/>
</LinearLayout>

当我在模拟器中运行它时,我只会得到第一张图像。它不做任何其他事情。有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: android eclipse button emulation imageview


    【解决方案1】:

    使用线性布局而不是相对布局可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      • 2017-07-13
      • 1970-01-01
      • 2014-10-25
      • 1970-01-01
      相关资源
      最近更新 更多