First of all I'd like to say it isn't any duplicate. My problem is tha I have to much items and I want to make them smaller to fill in gridview height. That's why I cannot use setMinimumHeight. I need something like setMaximumHeight but nothing like this is predicted by Android SDK. Additionally I don't have any row spacing so I cannot make it smaller.
image to help understand:
I want make itemw smaller height, I don't want any to be "cut" by the display border.
Related
I wanna create a group of image views as below, and I can update background images. I wonder whether I should create 7 image-views on the layout or I should create each image view programmatically, like creating a list? Thanks.
I'd say it depends on the data. Will you always have 7 or could you have less, or maybe even more? Do you need to display 7 or can it depend on the screen width? Do they need to be a certain size or can they shrink to fit on narrower screens?
If it's guaranteed to be always exactly 7 and you're happy for them to scale to fit the screen then I'd use an XML layout but if it can vary then I'd render it programatically using a horizontal RecyclerView to show as many as possible on the screen and allow the user to scroll through them.
I'm an Android newbie. I have an app whose main screen uses an ExpandableListView with only 5 rows. Is it possible to stretch these rows so that they fill the whole screen? Currently only half the screen is occupied and there is a large empty space.
I have tried match_parent, wrap_content for the list's vertical height but nothing helps. Please assist.
Changing the height attribute on the list does not help because it only tells the listview how much screen space it may occupy.
The individual items your list is displaying are not affected by this, as they will still follow their own layout rules on how to use available space in the listview.
To solve your issue, you might want to look into extending BaseExpandableListAdapter. You can define a custom layout for the listview items, in your case you'd probably just make the item views a bit bigger so they take up more space. You'll find detailed tutorials on how to do this all over the net.
However, using this approach (with a static list size of 5 items), you'll eventually run into the same issue again on devices with larger screens. Your custom list may now look like you want it to on a 4" smartphone, but have a large empty area on a 10" tablet device.
Depending on what purpose you are using the list for, you might want to rethink your UI design approach.
How can I create NxN grid which automatically scale its items to fit entire screen? I need something similar to GridView but without scrolling. I want to have all items visible and fit to screen dimensions.
Well you can get the size that the gridView can fit to, and then set each of the gridView's views size according to it.
This way, there will not have to be a scrolling at all.
So, for example, if you need an NxN grid and you have 100Nx100N pixels available, for each item give 100x100 pixels.
Of course, you might want to add some padding or separators between them, but that's the basic idea.
In order to get the gridView's size (so that you can set the size of each of its views), you can use this sample code I've made, which works on any type of view.
i'm implementing a activity where the user can see images from different sizes and proportions on a GridView. I don't want to modify this images proportions.
Is it possible with GridViews or my best option is to build a TableLayout and just add each image to a TableRow?
Example: If it loads a 3x4 image, i want it to scale to satify some width and height constraint and them merge the necessary GridView's elements to keep the 3x4 proportion rate.
My objective is to reach something like this: https://www.dropbox.com/s/6jmt2x5ly1k2p92/grid.png
It seems you can as a custom gridview, I haven't tested my own, and too low to comment. So on this link you will find an image on the bottom using a gridview notice that the last item is larger that the rest and the middle left item is also off scaled.
I want to stretch the row of a GridView to match the height of the screen in Android.
How do I do this?
You are in control over your row heights, by virtue of what you put in
them. Since your cells appear to have more than one widget, they are
presumably wrapped in a LinearLayout or something. Set your
LinearLayouts to be some specific height, and the rows will all be
that height.
Personally, I think you should be resizing your images if you are
going to have text above and below each image on a per-cell basis.
With the Reference commonsware link