Android ImageView Demonstration

Screenshot after five clicks on the PPS image
We put one medium size PPS.png image in the folder \res\drawable-mdpi to suit our emulator. The three sizes of the default icon are in the recommended 3 : 4 : 6 ratio as detailed below.
- 36 x 36 for small screens (drawable-sdpi\icon.png)
- 48 x 48 for medium screens (drawable-mdpi\icon.png)
- 72 x 72 for large screens (drawable-ldpi\icon.png)
Notice in the layout file that the src property setting of the ImageView refers to the image folder as "drawable" without any indication of size/resolution and that the file extension of the filename is omitted:
android:src="@drawable/icon"
The code of MainActivity.pas
namespace org.me.android_images; interface uses java.util, android.app, android.content, android.os, android.util, android.view, android.widget; type MainActivity = public class(Activity) private ppsImage : ImageView; public method onCreate(savedInstanceState: Bundle); override; method onClickPPS(v : View); end; implementation method MainActivity.onCreate(savedInstanceState: Bundle); begin inherited; // Set view from the "main" layout resource ContentView := R.layout.main; // Assign ImageView from layout resource. ppsImage := ImageView(findViewById(R.id.pps)); end; method MainActivity.onClickPPS(v : View); begin ppsImage.setY(ppsImage.getY + 5); end; end.
Layout 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" android:background="#ffffff" android:gravity="center_horizontal"> <ImageView android:src="@drawable/icon" android:paddingTop="30dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/pps" android:src="@drawable/pps" android:clickable="true" android:onClick="onClickPPS" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
Strings File
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">org.me.android_images</string> </resources>