Android Imageview insidelinear view stops an app -
here code: main.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="match_parent" android:layout_height="32dp" android:text="@string/image_title" /> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/image_date" /> <imageview android:id="@+id/imageview1" android:layout_width="42dp" android:layout_height="42dp" android:contentdescription="@string/image_description" android:scaletype="fitxy" android:src="@drawable/image1" /> </linearlayout>
amd here image1.png http://www.nasa.gov/sites/default/files/thumbnails/image/s84-27018.jpg
when try display image application has stopped unfortunately. other image works fine. there size problem image. please me solve issue? appreciate it. thanks
your image big load, must getting outofmemory exception.
you have scale image before display. there no point in loading 1024 x 1024 image display on 42dp x 42dp imageview.
bitmapfactory.options options = new bitmapfactory.options(); options.insamplesize = 4; bitmap mybitmap = bitmapfactory.decodefile(<picture url>, options); mybitmap = thumbnailutils.extractthumbnail(mybitmap, 200, 200); imgview.setimagebitmap(mybitmap);
Comments
Post a Comment