Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - fitting image in imageview

I'm implementing a widget where i'm trying to display a large image inside an image view (8mpx) like this :

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" android:id="@+id/widget"
    android:background="#000000"
    android:padding="15dp"
    android:layout_margin="5dp"
    android:layout_gravity="top|center_vertical|center_horizontal"


    >
<LinearLayout android:background="#ffffff" android:padding="1dp" android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content"  >
     <ImageView 
       android:adjustViewBounds="true"
       android:id="@+id/image"
       android:src="@drawable/sample"
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_gravity="top|center_horizontal"
       android:scaleType="fitXY"
       android:maxWidth="200dip"
       android:maxHeight="300dip"
       />
</LinearLayout>

In the emulator everything seems ok, but when i deploy to device, i get the "problem loading widget" message. the emulator is HVGA and my device has a 480x800 resolution. Any ideea what am i doing wrong ?

Thank you!

==================================================

As advised by you guys i've made a screenshot of the logcat. Here it is :

enter image description here

like image 934
maephisto Avatar asked Dec 03 '22 06:12

maephisto


1 Answers

imageview.setScaleType(ScaleType.CENTER_INSIDE); 
like image 98
Mohammad Ersan Avatar answered Jan 02 '23 16:01

Mohammad Ersan