Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - accordion widget

Tags:

I'm looking at best way of creating an Accordion-style widget such as on this page. Is there a way of achieving same effect using standard Android toolkit or do I need to build custom widget? If so - which one would you recommend extending if any?

like image 672
Bostone Avatar asked Jul 21 '09 22:07

Bostone


2 Answers

And in case you still wonder - this can be pretty much done with pair of button/layout stacked inside of the linear layout. Pseudo code follows

<LinearLayout android:orientation="vertical">     <Button android:text="Panel 1"/>     <SomeKindOfLayout android:id="@+id/panel1">             <!-- widgets in first panel go here -->     </SomeKindOfLayout>     <Button android:text="Panel 2"/>     <SomeKindOfLayout android:id="@+id/panel2" android:visibility="gone">             <!-- widgets in second panel go here -->     </SomeKindOfLayout>     <Button android:text="Panel 3"/>     <SomeKindOfLayout android:id="@+id/panel3" android:visibility="gone">             <!-- widgets in third panel go here -->     </SomeKindOfLayout>     <Button android:text="Panel 4"/>     <SomeKindOfLayout android:id="@+id/panel4" android:visibility="gone">             <!-- widgets in fourth panel go here -->     </SomeKindOfLayout></LinearLayout> 

Another thing to possibly try is stacking ExpandableListView-s on top of each other

like image 53
Bostone Avatar answered Oct 06 '22 01:10

Bostone


I have pushed android accordion view project at github. We use it for our customers, tested on 2.2, 2.3.x, 3.2 and 4.0.3. Works pretty good for us.

Going to add animation on fold/unfold in next step.

Here is small screenshot:

enter image description here

like image 29
Maciej Łopaciński Avatar answered Oct 06 '22 00:10

Maciej Łopaciński