【发布时间】:2011-11-27 12:03:12
【问题描述】:
我写了一个程序来测试MediaPlayer类,它有三个ImageButtons——“play”、“pause”和“stop”。一开始,我为三个ImageButtons使用了三个不同大小的.png图片,并且程序无法在我的AVD上运行,然后我将它们更改为三个具有相同大小的.png图片,然后它这次可以正常运行。
LinearLayout 中使用的图像是否必须相同大小??
这是布局文件:
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton
android:id="@+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/play">
</ImageButton>
<ImageButton
android:id="@+id/pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pause">
</ImageButton>
<ImageButton
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/stop">
</ImageButton>
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
您使用 android:src 而不是 android:background 有什么原因吗?
-
但这不是属性的问题
标签: android android-linearlayout imagebutton