Android 类似 Tweetdeck 的 UI

发布于 2024-10-23 18:17:49 字数 194 浏览 2 评论 0原文

我正在开始进行Android开发,我希望有一个类似于tweetdeck的界面:有几个从左到右布局的工作区(活动),用户可以通过水平手势在它们之间切换。 Android 桌面切换方式相同。

在 tweetdeck 中,标题栏中也有一些点,表示在哪一侧以及有多少个工作区。

它是标准的 Android 界面,还是定制的界面?我该如何做这样的事情?

I'm getting started with Android development, and I would like to have an interface similar to that of tweetdeck: there are several workspaces (activities) that are laid out left to right, and the user can switch between them with a horizontal gesture. The same way the Android desktops are switched.

In tweetdeck there are also dots in the titlebar, that indicate on which side and how many workspaces there are.

Is it a standard Android interface, or something custom built? How do I do something like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深爱成瘾 2024-10-30 18:17:49

您如何进行此操作将部分取决于您想要呈现的内容。如果有很多重量级页面,您需要考虑执行自定义 AdapterView。如果只有几个固定页面(例如在库存主屏幕中),您可以将其视为可滚动视图,并使用一些自定义逻辑来处理页面对齐。

以下是在 Android 原生启动器中实现此功能的自定义视图的链接。您感兴趣的部分主要位于 onTouchEventonInterceptTouchEventcomputeScroll 中。

https:// android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Workspace.java

How you go about this is going to be partially dependent on the content you want to present. If there are going to be many heavyweight pages you'll want to look into doing something like a custom AdapterView. If there are only a few fixed pages such as in the stock home screen you can treat it like a scrollable view with some custom logic to handle snapping to pages.

Here's a link to the custom view that implements this in the stock Android launcher. The bits you're interested in will mostly be in onTouchEvent, onInterceptTouchEvent, and computeScroll.

https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Workspace.java

节枝 2024-10-30 18:17:49

除了研究实际的 Android 代码(在另一个答案中引用)之外,一些人还提取了工作区(Launcher2)代码并将其隔离到可重用的视图组中。您可以在 github 中找到该作品 https://github.com/olibye/AndroViews

In addition to studying the actual Android code (referenced in another answer), some folks have extracted and isolated the workspace (Launcher2) code into a re-usable view group. You can find the work in github here https://github.com/olibye/AndroViews

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文