在 Android 中显示对话,就像 iOS 中的 iMessage 一样

发布于 2024-12-23 01:56:27 字数 447 浏览 2 评论 0原文

我正在尝试编写一个需要显示两个人之间的对话的 Android 应用程序。是否可以实现它,使其 UI 看起来像 iOS 。另一方面,是否可以在左侧显示第一个人的消息,在右侧显示第二个人的消息?

在此处输入图像描述

我的第一个想法是在 Java 代码中动态使用 TextView 数组,将它们的重力设置为左右。可以吗? OutOfMemoryException 怎么样?

问候 。

I'm trying to write an Android application that needs to show the conversation between two person. Is it possible to implement it so that it's UI looks like iMessage in iOS . On the other hand, is it possible to display the first person's messages on the left, and the second person's messages on the right ?

enter image description here

My first idea is to use an array of TextView, dynamically in Java code, setting their gravity to right and left. Is it OK? What about OutOfMemoryException ?

Regards .

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

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

发布评论

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

评论(1

执妄 2024-12-30 01:56:27

ListView (http://developer.android.com/reference/android/widget/ListView.html) 将成为 Activity 的根布局。您必须编写自己的 BaseAdapter 或 ListAdapter 并在 getView() 方法中交替视图的重力。

A ListView (http://developer.android.com/reference/android/widget/ListView.html) is going to be your root layout for the Activity. You will have to write your own BaseAdapter or ListAdapter and alternate the gravity of the views in the getView() method.

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