Alternative views instead of Stackviews for Android versions below for Android 3.0

I am trying to implement the StackView behavior in my application, but I believe that this widget is only available for Android version 3.0. I am an intermediate developer of the Android OS and therefore have limited knowledge of custom views.

Can someone provide some recommendations regarding how I can achieve StackView in android 2.2 / 2.3?

+4
source share
1 answer

There is no component in the SDK with this exact functionality up to API level 11 (3.0), so you will need to create your own custom view to get the desired effect.

The easiest / fastest way is to create a custom view that extends FrameLayout, as the FrameLayout children are automatically stacked on top of each other, and your custom view inherits this behavior. You will also want to redefine the way children are placed so that you adjust the x and y positions for the children depending on where they are on the stack.

You will need to make your own methods to move to the next / previous view - you will need to do this by reordering the child views (delete them all and then add them to the new order).

The solution I described does not include revising the view that you get with AdapterViews, so it is not suitable for a large number of layered elements.

Alternatively, find the StackView source code and copy it into your project, although this will probably also require copying a large number of other Android classes into your project, since StackView will undoubtedly gain access to private members of superclasses that are only available from the widget package ( without reflection).

+7
source

Source: https://habr.com/ru/post/1346620/


All Articles