i have wrote a program to test the MediaPlayer class, and it has three ImageButtons——”play”,”pause” and “stop”. at the beginning, i uses three different size .png pictures for the three ImageButtons, and the program cannot be run on my AVD, and then i changed them to three .png picutres that have the same size, then it runs correctly this time.
does the image uses in a LinearLayout must be the same size??
here is the latyout file:
<?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>
I have tested your code it is fine but problem was in images you remove .png in your image it will work. Cool because .png is already in image and you also add .png in images so that remove .png from image.