Home » Android » java – Android StackScrollLayout

java – Android StackScrollLayout

Posted by: admin May 14, 2020 Leave a comment

Questions:

I need help creating a Layout like the one Android uses to render notifications inside it’s notification Panel.

enter image description here

Basically what happens at the end of the view when notifications don’t fit the screen anymore is what interests me. Here is the view in Android source code.

Any suggestions or ideas are appreciated. Thanks!

How to&Answers:

1-Include the view inside your layout xml

<com.bartoszlipinski.flippablestackview.FlippableStackView
    android:id="@+id/stack"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

2-FlippableStackView is based on the specific PageTransformer used with the ViewPager. Therefore to fill the View you can use just a typical implementation of a PagerAdapter. In your onCreate method (or onCreateView for a fragment), setup all the parameters of the FlippableStackView.

 FlippableStackView stack = (FlippableStackView) findViewById(R.id.stack);
    stack.initStack(2);
    stack.setAdapter(mStackAdapter);
        //assuming mStackAdapter contains your initialized adapter

3-Important Note: The current implementation of the library will display the elements from the Adapter in the reverse order. In other words: view at position 0 of your adapter will be displayed at the bottom of the stack and view at position adapter.getCount()-1 will be visible first (available for the first flip).

for a working example and reference check the library here
FlippableStackView