25

I want to implement this behaviour [https://github.com/gleue/TGLStackedViewController] in an app that I am trying to make.

The closest thing/the effect that I want to achieve is how the Google Chrome browser behaves.

  1. Tile/card interface
  2. Be able to access a form of navigation (access other tabs) when user pulls down the address bar
  3. Be able to re-arrange the tabs in any order the user wishes

Photo taken from this Android Layout : How to implement a UI similar to deck of cards? SO question

Is there anyone out there who has tried to implement this kind of behavior? Do you guys know any libraries that can help achieve this effect? It would be very helpful! Thank you

Community
  • 1
  • 1
momoja
  • 938
  • 9
  • 23

2 Answers2

21

systemUI/Recents package, as mentioned by Andrei, can be your starting point. It adds a little more to the flat rendition of chrome tabs.

I have been meaning to refactor systemUI/Recents package ever since I got the L update. I finally got to it.

enter image description here

A sample project is hosted at: Link

Even though the viewgroup recycles, it updates the progress map (child properties) for all children on each scroll step. This will lead to lags with large data sets. For a few hundred, it should be fine.

The sample project uses Picasso for loading and caching images from LoremPixel. Since these are random images & may repeat, you can verify that they are bound correctly by looking at bottom left of the image.

Vikram
  • 51,313
  • 11
  • 93
  • 122
  • Hi Vikram, thank you for sharing that sample project and I am sure that it will help not just me but a lot more developers as well. I have already tried looking into that AOSP implementation, but the problem I have is that it's only for Kitkat and Lollipop right? I'm trying to support ICS as well. But thank you for this. – momoja Apr 04 '15 at 12:07
  • 2
    @momoja Hi, `DeckView` (and the AOSP code that its based on) uses APIs available only on Lollipop and above. So, no KitKat support either. I am hopeful that I will be able to bring the minimum sdk requirements down in the coming week(s). I cannot promise support for ICS right now :( - the github page will be updated with relevant info. – Vikram Apr 04 '15 at 15:37
  • Yes @Vikram I pray that you do. I wont mark your comment as the accepted answer...atleast not YET. Since the question is looking for pre Lollipop support. I hope you understand. I do hope that you can succeed and update it here because the community would very much appreciate the contribution. – momoja Apr 04 '15 at 15:50
  • @Vikram can you please refactor the code in `SystemUI/statusbar/stack` for those stackable cards of notifications in L+? I could put a bounty on a question if you can help me achieve it. – Alex Newman Jan 21 '17 at 14:12
7

If you feel like looking through the AOSP code, the functionality you are looking for is actually open-source and you can find it in Android 5.0 in the recent apps screen. This is the code you want to look at on github. The view you want to extract from AOSP is the RecentsView. This would be the best approach.

You could also consider extending StackView and overriding onLayout() so you get the children to lineup.

One other option is to extend ListView, override drawChild or layout methots and try to shift the views according to their position. You can find some inspiration here and here

Community
  • 1
  • 1
Andrei Tudor Diaconu
  • 2,157
  • 21
  • 26
  • Hi Andrei, thank you very much for this. Yes, I already tried looking into this, and if I read the code right, they are using a customized ScrollView for this...I don't understand it that much tho, that's why I am trying to implement it on a ListView and customizing drawChild using Camera and matrix operations. Thank you nonetheless. – momoja Apr 04 '15 at 12:11