I want to create listview with header which move with listviews scrolling. I tried it :
ViewGroup listviewheader = (ViewGroup) inflater.inflate(R.layout.listview_header , list1,false);
list1.addHeaderView(listviewheader);
But it only appears when user rise to top of the listview. I want that when user rise a little bit (everywhere in listview) then the header appear in top. How can i do it?
Check this library: https://github.com/ManuelPeinado/QuickReturnHeader
"A ListView/ScrollView header that hides when scrolling down and reappears immediately when scrolling up, regardless of how far down the list we've gone. Like the one from the Google Keep app."
https://github.com/felipecsl/QuickReturn
-- Quite easy and useful implementation
Related
I want to implement a header/list combination similar to what you see in the Instagram profile screen, where the header scrolls away and you scroll through the user's posts.
You can't use a scroll view that contains everything since that would mean having to load all the list items up front. And if you use the RecyclerView the scrollbar is in the RecyclerView and doesn't scroll the header away.
I suppose the header can be made into rows in the RecyclerView, but that seems kind of hacky. Is there a better way I'm not seeing?
Check out these scroll tricks using the new Toolbar class in Lollipop: scrolltricks
He implements the exact functionality Instagram has. The ActionBar scrolls away upon scrolling down.
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.
Possible? I know there's smoothScrollToPosition() (in api >= 8), but that doesn't make the requested element touch the top of the listview. It just says that the item will be visible.
I imagine I could measure each item somehow and set the scroll position manually, this doesn't help on my last few rows though, since those should not be allowed to scroll to the top anyway.
Use case - I want me users to pop open the keyboard and comment on an item in my ListView. The ime keyboard will cover some portion of the screen, so I want the 'focused' row to be touching the top of the view so they remember what they're commenting on.
Thanks
I think you can add a big & empty footerView when your user open the keyboard.
and remove the footerview when user close the keyboard.
if you add a big footerview, you can use ListView.SetSelection(last_row_pos)
After that, the last row will touch top of view.
I think you can use a set of flags in your manifest under your activity element which will allow you to do this. Please check the docs to see what your various options are.
I have a button in each item of a ListView whose background is defined by an XML, one background when enabled and another when disabled. When the ListView loads, it comes out correct. But, for some reason I can't figure out, if I scroll down and then scroll back up, the wrong background shows up.
I'd like to know the solution to this problem, but besides that, in general what I want to accomplish is this:
I have a button in the ListView to take the user to the website for the given item. If there is no website, I want the button to disappear, or be disabled. I seem to have the same problem with both options.
Thanks in advance for your efforts
It seems most likely that the problem lies with your getView() method. Android recycles views to save memory, so, for example, when you scroll down, it calls getView(int, View, ViewGroup) on your adapter where View is the item that just left the top of the screen. If you're not re-populating the item with the new data from the adapter, (ie, just returning convertView) it will put the View that left the top of the screen where the "new" one should be.
is it possible to programmically force a View inside a ScrollView NOT to scroll?
Like the alphabetic titles in the contacts list. The 'A' bar doesn't scroll when the user scrolls through the list of all contacts whose first names start with 'A'. When the user scrolls till the end of 'A', 'B' bar simply scrolls up from the bottom of ScrollView, finally reaplacing 'A' at the top and staying there.
My description is kind of abstract, hope you understand.
Also thanks in advance.
The contacts list uses the ListView and not the ScrollView. One way I think it can be done is to have a fixed header at the top. You can change its content depending on what is being displayed on the screen.
Attach a OnScrollListener to ListView. You will get the view with the first visible position in onScroll. Then change the content of the header according to the content in the view.
You don't need to add a header in your ListView for the first section in your list as it will be already handled in your ScrollListener. Keep the style for the header rows and the view at the top the same and you will have the illusion for the fixed header.
I think you need a combination of the "static text" approach with "section headers" within the ScrollView: the list should contain disabled/non-clickable items with the letters "A", "B", etc. When a section header scrolls above the top of the view, change the contents of the static TextView above the ScrollView to the contents of the header. I.e., when the "B" header item scrolls out of view, the TextView now contains "B".
Of course, the tough part will be detecting when a "section header" scrolls off the top, or comes into view when scrolling in the opposite direction.
For bonus points, use a "push up" Animation in the TextView when it's contents change to make it look like the list item is rolling into the TextView. (There is an example of this Animation in the API Demos app in the SDK in "...\view\Animation2.java").
UPDATE: after further review... here is some classes, etc. related towards making this work (it was a fun exercise for me!):
android.widget.AbsListView.OnScrollListener interface to see how to detect scrolling events. You'll need to keep track of the previous "top of view" position to determine which direction you are scrolling (to pick the slide-up or -down animation).
The Animation I listed above is not really what you want -- better off to look at the android.widget.TextSwitcher class and the push*.xml files in the SDK/android-X/data/res/anim directory.
You'll certainly need your own adapter subclass to inject section views into the list: getView(...) can set the row view's properties (bkgnd, text style, etc.) differently if the row is a section header or not. Re-use this code in your TextSwitcher view factory to populate the static TextView/Switcher above the list.
Have fun...!
As mentioned earlier you need a ListView. For an effect similar to that in the People app in Android 4+ I have used this excellent library (free and open source).