【发布时间】:2010-08-22 00:55:18
【问题描述】:
我的 imagebutton 代码不会响应“fill_parent”和“wrap_content”。 相反,它只显示图像的中间(因为它是一个非常大的图像)。 我尝试为图像设置特定值,但它仍然不起作用!有人可以帮帮我吗?
我在 res/drawable 文件夹中的 button.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/largishbutton" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/largerbutton2" /> <!-- focused -->
<item android:drawable="@drawable/largerbutton" /> <!-- default -->
</selector>
我在 res/layout 文件夹中的 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:layout_height="fill_parent"
android:layout_width="wrap_content"
/>
</RelativeLayout>
我尝试使用 LinearLayout,但应用无法运行,我尝试将 imagebutton 替换为 imageview,但按钮不起作用。
【问题讨论】:
标签: android eclipse image button imageview