ImageView Android example

ImageView basic Android sample.
ImagView using image formats like this PNG, JPG, GIF and etc.
Images is stored in res/drawable folder.
Application’s icons in:
drawable-hdpi
drawable-ldpi
drawable-mdpi

main.xml
Put into res/drawable this image:
semafor

 
<?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"
    />
 
       <ImageView
            android:src="@drawable/semafor_red"
            android:id="@+id/idImageViewSemafor"
            android:background="#66FFFFFF"
            android:adjustViewBounds="true"
            android:maxWidth="47dip"
            android:maxHeight="91dip"
            android:padding="10dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />    
 
</LinearLayout>

Main.java

 
package com.example.my_app;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
 
 
public class Main extends Activity {
private ImageView hImageViewSemafor;
 
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        hImageViewSemafor = (ImageView)findViewById(R.id.idImageViewSemafor);
 
    }
}
This entry was posted in Android Software Download and tagged , . Bookmark the permalink.


Comments are closed.



8,202 views