how to Expand and collapse listview on click of button? - android

I have a listview in my fragment which occupies around 25% of my screen size. I also have a stripdown button. So, I want that when a strip down is clicked, that that time list view should expand and cover around 50% of the screen size and then again when i click stripUp it should return to it's former state. Can you please suggest some techniques through which i can achieve this.
My listview is like this: say i have 25 elements then initially only 10 of them are visible and to see others i will scroll down in Listview. After that when i click on stripDown button then number of visible items will increase to 15 and to see other elements i will scroll down.
Thanks in advance.

Try the ListView section on the Api demo prior to honey comb. There are several examples that depict the usage of ListViews. It also includes an ExpandableListView and a regular ListView with an expandable effect.
You can find the demos from you Android SDK installation on your machine.
android-sdk/samples/android-x/ApiDemos

Related

Scrolling of list below another view

I have seen an app which has different type of scrolling. I hope images attached will be able to explain it. Here the list when scrolled up, moves up by taking DownloadAll, Playall button up too. Later on DownloadAll and PlayAll button stops going up and only the list scrolls up.
I don't know what this is called as. I tried searching, but could not find anything similar.
How can I achieve this type of scrolling?
Take a look at "Libraries for developers" it has a section of listview where you can find different styles of listviews (plus scrolling animations such as sticky, animated scrollview, flabby etc...)

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.

how to scroll to a particular screen location without actually scrolling

I have a scrollview inside which I have 5 imageviews say IMV1,IMV2...IMV5 . Now on scrolling,one by one all imageviews are shown in device screen. Now I have a drawer with 5 buttons say 1,2 ..5.
Now take us a scenario,
Currently I am on first imageview. Now when I click on button 5 in the drawer.
I need IMV5 to show on the screen without scrolling.It can be obtained
through smoothScrollBy/scrollTo to y equal to 5*screenHeight. But here it
scrolls through all intermediate imageviews.
Please note,I don't wish to affect scroll feature.For above example,
After I reach IMV5,when I scroll up,it should scroll to IMV4 and so on.
Is there any way to obtain it .Please suggest.
Thanks In Advance.
P.S. If you need some more clarification,please let me know.
You can achieve this easily using a ListView instead of ScrollView.
What you can do is:-
Add all the imageviews to a ListView.
This will fulfill your scrolling requirement, as ListView automatically handles scrolling if its content's size is grater than the screen size.
Now use the listView.setSelection(position) on click of the buttons.
It will scroll to the selected imageview without giving the scrolling effect
Hope this helps.
It can be achieved through ScrollView too.. All you need to do is get the View at that position. Then call requestFocus() on the obtained view.
For example:- If you press Button 5, then IMV5.requestFocus() will do it for 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.

Animated vertical sliding menu in android

I need to make a sliding vertical menu in android as below. user slide the screen to up or down for selecting related item and the selected item must be bigger than the other items. How can I do that in android? Any idea would be great.
Edit:
I'm very desperate and need some help. how to do this in android?
http://iphone2020.wordpress.com/2012/06/10/uitableview-tricks/
This can probably be achieved by using the Camera.setTranslate function. See Android: Vertical ListView with overlaped rows and Android: vertical 3d listview for similar questions (with solutions)

Categories

Resources