How to implement custom listview with "stacking" feature Android - android

I want to create a custom listview that scroll horizontally and stacks the last 4 items in the view instead of allowing them to go off screen. The stack should look something like this: . So if a user scrolls all the way to the left they see a regular listview, but as they scroll right, if an item was supposed to go off screen, it is instead stacked behind the last item in the list, with a max of 4 stacks. What's a good basic way to accomplish this? I already found the horizontally scrolling listview library I wanted to use but don't know where to start on the stacking part.

Related

How to display one item at a time in a list in an Android Activity

I am new the Android development (3 weeks).
I'd like to create an Activity that allows the user to scroll through a list of items. I'd like only one item to occupy the width/height of the screen at any given time. At the same time, I'd like for the items to be able to scroll smoothly (up/down), similarly to facebook/instagram. During run-time, items will be pushed on top of the stack/list (like a news feed in FB).
What is the best way to accomplish this? What are the pros/cons between using a ListView, LinearLayout (Vertical) items, a List of Buttons added on top of one another? Or should I use Fragments that display on top of one another? How would I implement the ability to display only one item at a given moment?
The answer is to use a ViewPager: http://developer.android.com/reference/android/support/v4/view/ViewPager.html
By default, the motion is horizontal, but there are examples that show how to make it vertical.

Android: ListFragment, how to show only one list item on whole screen

how can I set ListFragment to show each of its items on whole screen? And of course, when you swipe up and down, whole item should be available at a time, the list shouldn't stop scrolling in the middle of two items. Thanks for any suggestions.
You have two choices:
Add a OnScorllListener and implement logic to "settle" the list
after a scroll.
Make a vertical ViewPager. You could copy the source code and flip everything from using X to using Y.

How to create a gridview with spacing at the top

I was looking to create a GridView that stretches across the entire screen. However, when the user first opens the screen, the top of the first item should be about halfway up the screen.
For example lets say we have a GridView of 12 items displayed 3 x 4. When the user first opens the screen, only the first six items would be seen with a large margin at the top of the screen. The user can then scroll the list to see the other items. The top items would eventually reach all the way to the top of the screen.
If I was using a ListView, this is simple. I merely create a 0dp headerView with a large top margin. But, GridViews do not allow for headers. What is the best way to handle this situation?
Normally, you DO NOT make a GridView inside a ScrollView. It's not recommended! But sometimes you have no choice and you need to addHeaderView() on a GridView (But I repeat, it isnt recommended).
So, to make this happen, you have to make a custom GridView. This answer will be usefull in your case: Grid of images inside ScrollView
I had a same situation and I used this one: HFGridView by #SergeyBurish! Very simple and really great. (See the last answer here: A GridView with header and footer).
Hope this will be helpful.

Create UI for Application

I want to create Application which looks i this way:
I will have lets say 6 Scroollable Lists (A,B,C,D,E,F). They should change by touch event.
For example we see Scrollable List B, I touch screen and move to left and next I see Scrollable List C, I touch screen and move it to right and I see Scrollable List B).
The name do Scrollable List (NameOfScrollableList shoud be change with touch event for Scrollable List)
How to do it? (I am not asking for code. I want to know a proper aproach to this problem :) )
If i understand correctly you want to horizontally scroll between your lists. Have a look at ViewPager, which is ideal for horizontal scrolling. The put a ListView inside each page of ViewPager.
That's what I'd do.
Most probably you are looking for ViewPager
This might help you

ListView with a (half- and or) hidable header

My Problem, is that I don't even know what to search for.
I want a ListView.
This ListView has some Elements with a "sticky" state.
If I scroll down the List on the device, I want that all ListElements with state "sticky", to be sticky ontop of the list (non-scrollable) till there is another one "pushing it away". The rest of the elements are supposed to scroll as normal.
I've seen that kind of List in the Google Market. If you have a big screen you can see that list on the Detailview of any app on the left side or if you have android JB, the same effect is on the google search bar in the google now app.
Image One: You can see the normal ListView on the left side
Image 1 http://www.android-hilfe.de/attachments/android-app-entwicklung/120884d1347256368-suche-stichwort-fuer-suche-nach-spezieller-listview-liste1.png
Image Two: You can see the normal ListView scrolled up a bit
Image 2 http://www.android-hilfe.de/attachments/android-app-entwicklung/120885d1347256368-suche-stichwort-fuer-suche-nach-spezieller-listview-liste2.png:
Image Three: You can see, what I actually want. The View is scrolled up but the "sticky" price does not disappear. Instead of that all other elements, went under the "sticky" one
Image 3 http://www.android-hilfe.de/attachments/android-app-entwicklung/120886d1347256368-suche-stichwort-fuer-suche-nach-spezieller-listview-liste3.png:
How do I do that?
I think that you meant to do some "synchronized scrolling".
There's a great post explaining how they've done in on Google Play:
http://www.pushing-pixels.org/2011/07/18/android-tips-and-tricks-synchronized-scrolling.html
Hope that's what you were looking for..
I believe that is a separate component, not related to ListView in any way.
Just create the header, let it be a RelativeLayout, or LinearLayout, and fill the rest of the area with the ListView set to fill_parent. Then, when you'll scroll the ListView, the "header" will stay sticky (as it is a separate component), and the list will scroll down.

Categories

Resources