Adding minimum height to a list - android

I am trying managing 4 lists under the same header as like it is posted in https://github.com/kmshack/Android-ParallaxHeaderViewPager. The problem I am facing is, my list has only fewer items on swiping pages, The header seems resizing. Is there a way to add a minimum height to the list to that it never falls short of height.

Related

How to design single row of images?

I am trying to build a row of images. I want the number of images to increase based on screen width. For example, in portrait mode there may be 3 images present, but in landscape there would be five.
I have tried using a GridView, but I am having trouble stopping it from being populated after the first row has been filled (it goes to the next row). Is there an alternative view I should be using or is a GridView the right approach?
If you only want 1 row, then use a LinearLayout. If it needs to scroll, embed it in a HorizontalScrollView.
If you aren't scrolling you can then inflate and add each image, depending on available space.
You could make it more complex by creating custom classes, etc.
You can also try the Two-Way GridView (I've used it - it works great)
How to make grid-view horizontally scrollable in android
I have found a suggestion based off of this. Once a max width has been exceeded on the LinearLayout, simply stop adding to it!

Are there Example for InsideOut Design and Clustering of Collections in Android

I saw in DevBytes Android 4.4: Collectons the possiblility to have a StaggeredGridLayout which will handle a dynamic adding/removing of Items. Its possible to fill the items in a vertical order, till you have no space anymore, and then continue on the next column, whithout knowing the amount of items when specifing the layout.
Im looking for a view , which will look like the Android Play Market, but its size expands horizontally, it should just contain simple squared items, like cards.
Example:
[1, 4,..,.., n*Y+1, (n+1)*Y+1]
[2, 5,..,..,n*Y+2, (n+2)*Y+1]
[3, 6,..,..,n*Y+3, empty]
[Y,2Y,..,..,n*Y+Y, empty]
Somehow, it should be a horizontal List, where i can put in each item a vertical List fitting as much items as needed to fill the screen. but i think thats pretty awful to implement and to maintain all elements/items.
The Problem with GridLayout is that i need to know the amount of Items in advance. I was searching the hole day for sth. but i couldnt find anything similiar to which fits my needs.

Stretch ExpandableListView to fill screen vertically

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.

android scrollbar length with different item sizes

I have a listview with a comments. Comments has different length(from 1 line to 20, for example).
And while I'm scrolling this listview, standard scrollbar increases and decreases, depending of what the comment I'm scrolling in this moment.
Why is it happening?
Maybe this is what you need. Just set it false
setSmoothScrollbarEnabled
I found this online on why this happens. Not sure why Google decided make lists height-agnostic.
If the ListView contains items with variable heights, the ListView has no way of knowing the full height of all the items it contains so the height of the thumb is calculated based on the number of items in the view and the number of items currently visible. The number of items currently visible varies, so the thumb height varies too.
On iOS the equivalent component (UITableView) requests the height of all items from the UITableViewDataSource before the view is shown so the overall thumb size can be known and kept consistent.
Max Howell, Last.fm developer
Why does the scroll bar change its length during scrolling?

How can I find the measured height of views?

I need to calculate the measured height of my views without measuring all views, because these views contain images fetched from the internet. When I measure the views, they download images to memory and I an catch out of memory exception. I use custom ScrollViews, which work like ListViews, display some part of views and when scroll, add to bottom or top.
How can I calculate the height of all my views without throwing out of memory exceptions?
Or how can I make ListView calculate its height before rendering views?
You can use getLeft(), getTop(), getRight() and getBottom() these method's on view. for more information . see following link
http://developer.android.com/reference/android/view/View.html
You answered your own question:
display some part of views and when scroll, add to bottom or top.
ListView does NOT know the heights of items it has not yet seen. It lays out some or all of the items it knows, adds an extra bit of UI at top and bottom to visually indicate that there may be more items, and scrolls that. The total scrollable range for ListView can change as it adds more items.

Categories

Resources