简体   繁体   English

像Chrome for Android一样创建用户界面

[英]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. 我想在我想要的应用程序中实现此行为[ https://github.com/gleue/TGLStackedViewController]

The closest thing/the effect that I want to achieve is how the Google Chrome browser behaves. 我想要达到的最接近/效果是Google Chrome浏览器的行为方式。

  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? 从这个Android布局拍摄的照片:如何实现类似于卡片组的UI? 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. AndreisystemUI/Recents包可以作为您的起点。 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. 自从我获得L更新以来,我一直想重构systemUI/Recents包。 I finally got to it. 我终于明白了。

在此输入图像描述

A sample project is hosted at: Link 示例项目托管在: Link

Even though the viewgroup recycles, it updates the progress map (child properties) for all children on each scroll step. 即使viewgroup再循环,它也会更新每个滚动步骤中所有子项的进度图(子属性)。 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 . 该示例项目使用Picasso从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. 如果您想查看AOSP代码,您正在寻找的功能实际上是开源的,您可以在最近的应用程序屏幕中的Android 5.0中找到它。 This is the code you want to look at on github . 是你想在github上看到的代码。 The view you want to extract from AOSP is the RecentsView . 要从AOSP中提取的视图是RecentsView This would be the best approach. 这将是最好的方法。

You could also consider extending StackView and overriding onLayout() so you get the children to lineup. 您还可以考虑扩展StackView并覆盖onLayout(),以便让孩子们进行阵容。

One other option is to extend ListView, override drawChild or layout methots and try to shift the views according to their position. 另一个选项是扩展ListView,覆盖drawChild或布局methots并尝试根据它们的位置移动视图。 You can find some inspiration here and here 你可以在这里这里找到一些灵感

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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