我写了一个程序来测试MediaPlayer类,它有三个ImageButtons - “播放”,“暂停”和“停止”。在开始时,我使用了三种不同尺寸的.png图片作为三个ImageButton,并且该程序无法在我的AVD上运行,然后我将它们更改为三个具有相同大小的.png picutres,然后这次它正确运行。LinearLayout中的图像是否必须具有相同的大小?
在LinearLayout中使用的图像必须是相同的大小?
这里是latyout文件:
<?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? – josephus
但它不是属性的问题 – zenis