Create UI like Chrome for Android

删除回忆录丶 提交于 2019-11-28 19:04:23

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/26094666/create-ui-like-chrome-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!