BVtp
BVtp

Reputation: 2480

Sliding a fragment over another fragment

I want to be able to slide a fragment over another one like in Shazam app :

https://i.sstatic.net/SmGwx.png - starting state

https://i.sstatic.net/3vdGM.png - sliding

https://i.sstatic.net/cgmDL.png

How is that (or can be) implemented?

Upvotes: 3

Views: 1137

Answers (1)

Gauthier
Gauthier

Reputation: 4978

Let's say layout1 is the layout in the background and layout2 is the layout that can slides over layout1.

You could create a ScrollView where the first element has the same height of layout1 and full width. Make that element transparent so that layout1 is visible and clickable and put layout2 below it.

Now you put layout1 and the ScrollView in a FrameLayout. If ScrollView has enough content you will be able to scroll it.

It would give something like :

<FrameLayout>
  <Layout1/>
  <ScrollView>
    <LinearLayout> 
      <View/> // Same height as Layout 1 and width is match_parent
      <Layout2/>
    </LinearLayout>
  </ScrollView>
</FrameLayout>

Upvotes: 1

Related Questions