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?
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
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With