Thanks for your help, but I think you have no idea - how else would you
organize the views inside cells? You maybe have worked with list view? What
do you use there for the rows?
And I prefer not having to scale the bitmaps.
Am Montag, 18. März 2013 22:17:18 UTC+1 schrieb bob:
>
> I've never used GridView, but that sounds fishy using a LinearLayout for
> each cell.
>
> Why not just use wrap_content, wrap_content for the ImageViews and scale
> all bitmaps using this:
>
> public static Bitmap *createScaledBitmap* (Bitmap src, int dstWidth, int
> dstHeight, boolean filter)
> Added in API level 1
> Creates a new bitmap, scaled from an existing bitmap, when possible. If
> the specified width and height are the same as the current width and height
> of the source btimap, the source bitmap is returned and now new bitmap is
> created.
> Parameters
> src
> The source bitmap.
> dstWidth
> The new bitmap's desired width.
> dstHeight
> The new bitmap's desired height.
> filter
> true if the source should be filtered.
> Returns
> The new scaled bitmap or the source bitmap if no scaling is required.
>
>
>
> On Monday, March 18, 2013 3:55:37 PM UTC-5, user123 wrote:
>>
>> They are in a linear layout, each cell has a (linear) layout... This also
>> would cause a class cast exception.
>>
>>
>> Am Montag, 18. März 2013 20:15:17 UTC+1 schrieb bob:
>>>
>>> I think this only works if your images are in a LinearLayout.:
>>>
>>> *LinearLayout.LayoutParams params = new
>>> LinearLayout.LayoutParams(width, newH);*
>>>
>>> Maybe change LinearLayout to *GridView*?
>>>
>>>
>>>
>>>
>>> On Monday, March 18, 2013 12:51:58 PM UTC-5, user123 wrote:
>>>>
>>>> Yes, sorry, it was in the original code, and I removed it before
>>>> pasting here (thought it could be unnecessary)
>>>>
>>>> the line is
>>>>
>>>> double factor = loadedBitmap.getWidth() / (loadedBitmap.getHeight() *
>>>> 1d);
>>>>
>>>> Am Montag, 18. März 2013 18:08:56 UTC+1 schrieb bob:
>>>>>
>>>>> Shouldn't you convert the getWidth() and getHeight() to *double*s
>>>>> before your division?
>>>>>
>>>>> Thanks.
>>>>>
>>>>>
>>>>>
>>>>> On Monday, March 18, 2013 9:41:26 AM UTC-5, user123 wrote:
>>>>>>
>>>>>> I 4 - colums grid where the items are an image on top and bellow a
>>>>>> textview. The image fills all the available width - no padding or
>>>>>> anything.
>>>>>>
>>>>>> My images will all have exactly the same size.
>>>>>>
>>>>>> Now I want that the height of the view adjusts to the width - to keep
>>>>>> the images proportional. AFAIK this is not possible with Android's
>>>>>> scaling
>>>>>> types. So I put this code after I load the bitmap (it's feched from the
>>>>>> web):
>>>>>>
>>>>>> imageView.post(new Runnable() {
>>>>>> @Override
>>>>>> public void run() {
>>>>>> double factor = loadedBitmap.getWidth() /
>>>>>> (loadedBitmap.getHeight());
>>>>>>
>>>>>> int width = imageView.getWidth();
>>>>>>
>>>>>> int newH = (int)(width * factor);
>>>>>> LinearLayout.LayoutParams params = new
>>>>>> LinearLayout.LayoutParams(width, newH);
>>>>>> imageView.setLayoutParams(params);
>>>>>> //convertViewFinal.invalidate(); //doesn't
>>>>>> help
>>>>>> //convertViewFinal.requestLayout(); //doesn't
>>>>>> help
>>>>>> }
>>>>>> });
>>>>>>
>>>>>> It works for most of the images, but on some, it doesn't show any
>>>>>> image (the imageview looks like GONE), and in some cases this also
>>>>>> breaks
>>>>>> the grid layout. Why is it? I know that the bitmaps are fine, because,
>>>>>> in
>>>>>> my testing application, I loop through the same bitmaps many times -
>>>>>> they
>>>>>> appear after x items in the grid again, and they are fine. And each time
>>>>>> I
>>>>>> load the grid, different items have the problem.
>>>>>>
>>>>>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.