package com.AndroidLoadImageView;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
public class AndroidLoadImageViewActivity extends Activity {
String imagefile ="/sdcard/IMG_9331.JPG";
/** 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.image);
Bitmap bm = BitmapFactory.decodeFile(imagefile);
image.setImageBitmap(bm);
}
}
<?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:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
Related:
- ImageView
- Reduce Bitmap size using BitmapFactory.Options.inSampleSize
- Read Exif of JPG file using ExifInterface
This comment has been removed by the author.
ReplyDelete