[SOLVED] Dialogs don't resize the way I expect them to

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

[SOLVED] Dialogs don't resize the way I expect them to

Postby ravon » Sun Feb 07, 2010 10:33 am

I have a title-less dialog which displays an image downloaded from a web address. This mostly works the way I want to, that is the dialogs wrap nicely around the image giving it a nice border. However, on some of the images the dialog is too wide causing not-so-nice grey borders around the image.

I'm starting to think that it only does this on images which are scaled down in the ImageView.

XML for the dialog layout:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout android:id="@+id/LinearLayout01"
  4.  
  5.              xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.              android:orientation="vertical"
  8.  
  9.              android:layout_height="wrap_content"
  10.  
  11.              android:layout_width="wrap_content">
  12.  
  13.    <ImageView android:src="@drawable/noimage"
  14.  
  15.              android:id="@+id/drink_image"
  16.  
  17.              android:scaleType="centerInside"
  18.  
  19.              android:layout_height="wrap_content"
  20.  
  21.              android:layout_width="wrap_content"
  22.  
  23.              android:layout_gravity="fill">
  24.  
  25.    </ImageView>
  26.  
  27. </LinearLayout>
  28.  
  29.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


And the code for creating it:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. final Dialog dialog = new Dialog(ctx);
  2.  
  3. dialog.setCanceledOnTouchOutside(true);
  4.  
  5. dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  6.  
  7. dialog.setContentView(R.layout.article_image_view);
  8.  
  9. ImageView imageView = (ImageView) dialog.findViewById(R.id.drink_image);
  10.  
  11. ImageLoader.getInstance().load(imageView, url, true);
  12.  
  13.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


See attached images for the result
Attachments
android_dialog2.png
&quot;Broken&quot; dialog
android_dialog2.png (85.46 KiB) Viewed 316 times
android_dialog1.png
Working dialog
android_dialog1.png (45.21 KiB) Viewed 316 times
ravon
Freshman
Freshman
 
Posts: 2
Joined: Sun Feb 07, 2010 10:18 am

Top

Postby ravon » Thu Feb 11, 2010 10:45 am

Setting android:adjustViewBounds="true" on the ImageView solved the aspect ratio issues.
ravon
Freshman
Freshman
 
Posts: 2
Joined: Sun Feb 07, 2010 10:18 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests