Friday, March 18, 2011

Re: [android-developers] Re: Problem positioning scaled images68

R
Sjcent from my Motorola phone.

Cliff Davies <cliff.davies@gmail.com> wrote:

>I'm quite bamboozled by this. I would have thought that the width and
>height of an ImageView would have scaled with the image that's being scaled.
> Just giving a final quick shout to see if anyone knows if I'm overlooking
>something?
>
>On Thu, Mar 17, 2011 at 8:35 PM, Cliff Davies <cliff.davies@gmail.com>wrote:
>
>> I'm trying to create a 2 x 3 set of ImageViews which use scaled down
>> images. The three rows are spaced equally to fit inside a LinearLayout (by
>> using three equally weighted linear layouts). If I put two images in each
>> row and use centerInside, fitStart or any other scale type that maintains
>> the aspect ratio, the images appear the correct size but are not positioned
>> adjacent to each other horizontally. Horizontally each is within a space
>> equal to the unscaled image width, so there is a large gap between them.
>>
>> <LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content"
>> android:orientation="vertical" android:layout_height="fill_parent">
>> <LinearLayout android:id="@+id/linearLayout3"
>> android:layout_width="wrap_content" android:layout_height="fill_parent"
>> android:layout_weight="1"> <ImageView android:layout_width="wrap_content"
>> android:layout_height="wrap_content" android:id="@+id/imageView1"
>> android:scaleType="fitStart"></ImageView> <ImageView
>> android:layout_width="wrap_content" android:layout_height="wrap_content"
>> android:id="@+id/imageView2" android:scaleType="fitStart"></ImageView>
>> </LinearLayout> <LinearLayout android:id="@+id/linearLayout4"
>> android:layout_width="wrap_content" android:layout_height="fill_parent"
>> android:layout_weight="1"> <ImageView android:layout_width="wrap_content"
>> android:layout_height="wrap_content" android:id="@+id/imageView3"
>> android:scaleType="fitStart"></ImageView> <ImageView
>> android:layout_width="wrap_content" android:layout_height="wrap_content"
>> android:id="@+id/imageView4" android:scaleType="fitStart"></ImageView>
>> </LinearLayout> <LinearLayout android:id="@+id/linearLayout5"
>> android:layout_width="wrap_content" android:layout_height="fill_parent"
>> android:layout_weight="1"> <ImageView android:layout_width="wrap_content"
>> android:layout_height="wrap_content" android:id="@+id/imageView5"
>> android:scaleType="fitStart"></ImageView> <ImageView
>> android:layout_width="wrap_content" android:layout_height="wrap_content"
>> android:id="@+id/imageView6" android:scaleType="fitStart"></ImageView>
>> </LinearLayout> </LinearLayout>
>>
>> This is the case if I set the Src in the XML layout or if I add the images
>> using addImageResource at run time.
>>
>> I know I can create my own custom view for the layout which will contain
>> the images, and calculate the requisite image sizes in the onSizeChanged
>> function. But before I do that I was wondering if I'm missing something
>> obvious or if there's some view type that caters for this automatically?
>>
>> Thanks,
>>
>> Cliff
>>
>
>--
>You received this message because you are subscribed to the Google
>Groups "Android Developers" group.
>To post to this group, send email to android-developers@googlegroups.com
>To unsubscribe from this group, send email to
>android-developers+unsubscribe@googlegroups.com
>For more options, visit this group at
>http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment