RSS

Search Engine

Monday, December 27, 2010

Working With Images In Android From Basic Application

Simply Displaying An Image


The ImageView layout component is the base element used for displaying images in Android. Download Any image and copy it into res/layout/drawable-mdpi in your project.

main.xml

<ImageView

android:id="@+id/images"

android:src="@drawable/image"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

/>


This ImageView loads the any downloaded image you downloaded. Add this to the res/layout/main.xml file below the TextView.

And JAVA Code given below.


package com.tuto.image;


import android.app.Activity;


public class Images Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

ImageView image = (ImageView) findViewById(R.id.images);

}

}


All that was added to the default code is how to get the ImageView component from the layout and store it in a variable. We'll do more with this in the next examples.

So this are the simple imageview for displaying in android.

0 comments:

Post a Comment