[android-developers] Re: Different sized images, arrangement and layout problem
ScrollView can only hold one view, so put a LinearLayout in there (orientation horizontal). Put three LinearLayouts in that LinearLayout, use layout_weight to give them equal spacing (doesn't matter what you set each weight to as long as they each get equal weight and as long as those three are the only immediate children of the wrapping LinearLayout.) The weights indicate how large a portion of the free space each layout should get, after they've each been allotted the width they request in layout_width, so set each of them to width=0dp, which means all the space is free space and the weights should distribute all available width. Once that's done you have your three columns, so just set each imageview you add to them to have width=fill_parent and an appropriate scaling type and you're done. On Mar 29, 1:12 am, Farhan Tariq farhan@gmail.com wrote: Hi everyone, I need to make an application that would show a number of images on the screen. The images can vary in height and width. I want to be able to show the images in a scrollView, such that there are no empty spaces between images. So... 1 - its a scrollable view, 2 - with 3 columns. Each column has a fixed width, 3 - and each image of different heights and widths adjusts its width according to the width of the column. The number of images is not known, and they would be added to the scrollView at runtime. How do I construct this view? Would scrollview be a good choice? Can I have a gridView for the purpose? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Different sized images, arrangement and layout problem
In that case, I would have to add to one of the 3 linear layouts usings their id, no? I would also need to keep track of which linear layout I added to first, so that I add the next image to the next one. There would be a lot of 'if's executing at run time. Can I have a gridView with different heights of images, fitting together perfectly? On Thu, Mar 29, 2012 at 12:28 PM, EhyehAsherEhyeh jacobsen.ar...@gmail.comwrote: ScrollView can only hold one view, so put a LinearLayout in there (orientation horizontal). Put three LinearLayouts in that LinearLayout, use layout_weight to give them equal spacing (doesn't matter what you set each weight to as long as they each get equal weight and as long as those three are the only immediate children of the wrapping LinearLayout.) The weights indicate how large a portion of the free space each layout should get, after they've each been allotted the width they request in layout_width, so set each of them to width=0dp, which means all the space is free space and the weights should distribute all available width. Once that's done you have your three columns, so just set each imageview you add to them to have width=fill_parent and an appropriate scaling type and you're done. On Mar 29, 1:12 am, Farhan Tariq farhan@gmail.com wrote: Hi everyone, I need to make an application that would show a number of images on the screen. The images can vary in height and width. I want to be able to show the images in a scrollView, such that there are no empty spaces between images. So... 1 - its a scrollable view, 2 - with 3 columns. Each column has a fixed width, 3 - and each image of different heights and widths adjusts its width according to the width of the column. The number of images is not known, and they would be added to the scrollView at runtime. How do I construct this view? Would scrollview be a good choice? Can I have a gridView for the purpose? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Different sized images, arrangement and layout problem
I don't believe so, but I am not absolutely certain it's impossible. As for keeping track of which layout to add to in my example, I'd just use an array of LinearLayouts, which you find on Activity creation, then keep an int to increment each time you add an image and use that modulus 3 (or however many columns you want) to index the array: linearLayoutArray[index%3].addView(...); index++; On Mar 29, 11:30 am, Farhan Tariq farhan@gmail.com wrote: In that case, I would have to add to one of the 3 linear layouts usings their id, no? I would also need to keep track of which linear layout I added to first, so that I add the next image to the next one. There would be a lot of 'if's executing at run time. Can I have a gridView with different heights of images, fitting together perfectly? On Thu, Mar 29, 2012 at 12:28 PM, EhyehAsherEhyeh jacobsen.ar...@gmail.comwrote: ScrollView can only hold one view, so put a LinearLayout in there (orientation horizontal). Put three LinearLayouts in that LinearLayout, use layout_weight to give them equal spacing (doesn't matter what you set each weight to as long as they each get equal weight and as long as those three are the only immediate children of the wrapping LinearLayout.) The weights indicate how large a portion of the free space each layout should get, after they've each been allotted the width they request in layout_width, so set each of them to width=0dp, which means all the space is free space and the weights should distribute all available width. Once that's done you have your three columns, so just set each imageview you add to them to have width=fill_parent and an appropriate scaling type and you're done. On Mar 29, 1:12 am, Farhan Tariq farhan@gmail.com wrote: Hi everyone, I need to make an application that would show a number of images on the screen. The images can vary in height and width. I want to be able to show the images in a scrollView, such that there are no empty spaces between images. So... 1 - its a scrollable view, 2 - with 3 columns. Each column has a fixed width, 3 - and each image of different heights and widths adjusts its width according to the width of the column. The number of images is not known, and they would be added to the scrollView at runtime. How do I construct this view? Would scrollview be a good choice? Can I have a gridView for the purpose? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en