I am trying to create a view I found on "developer.android.com", namely the top left one on the following image (I am not allowed to post images):
Layout from developer.android.com
It looks like one can choose between different 'cards' which are layered on top of each other.
I found that a FrameLayout
will layer multiple child views, so I created the view in following way:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="190dp"
android:layout_height="230dp"
android:layout_marginLeft="110dp"
android:layout_marginTop="100dp"
android:background="#FF0000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="190dp"
android:layout_height="230dp"
android:layout_marginLeft="70dp"
android:layout_marginTop="140dp"
android:background="#00FF00"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="190dp"
android:layout_height="230dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="180dp"
android:background="#0000FF"
android:orientation="horizontal" >
</LinearLayout>
</FrameLayout>
This will give the image of multiple views layered, but I don't know how to cycle through the different views. I tried looking for scrolling over the z-axis in a FrameLayout
, but this did not give me any helpful results.
So my question is: How can I create a layout which allows scrolling through the child views over the z-axis by swiping the screen? Thank you in advance.
It looks like one can choose between different 'cards' which are layered on top of each other.
Android has a StackView
widget that offers this UI. You tend to see it more in app widgets, as typical Android app widgets like Photo Gallery and YouTube employ a StackView
.
Here is a sample project demonstrating the use of a StackView
in a traditional UI, not in an app widget.