简体   繁体   中英

Create UI like Chrome for Android

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

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.

在此输入图像描述

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM