我正在为 Android 开发一个聊天应用程序。聊天画面应该如何?谁能告诉我在 XML 布局中应该使用哪些 View ?它是一个编辑文本和一个 ListView 吗?请帮助。我需要制作一个聊天屏幕,就像我们在 Gtalk 中看到的那样。两个人的聊天消息应该对齐到屏幕的相对两侧(参见 Gtalk 聊天框对齐样式)。这就是我想要的。我如何实现这种布局? http://upload.wikimedia.org/wikipedia/en/7/75/Google_talk.gif
最佳答案
找到合适的。所以我在这里分享
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<TextView
android:text="@string/text"
android:id="@+id/textOutput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp" />
</ScrollView>
<LinearLayout
android:id="@+id/linearLayout1"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:baselineAligned="true">
<EditText android:layout_weight="1" android:id="@+id/textInput"
android:layout_height="45dp" android:layout_width="0dip">
<requestFocus></requestFocus>
</EditText>
<Button android:text="Send"
android:layout_height="45dp" android:layout_width="125dp"
android:id="@+id/btnSend"></Button>
</LinearLayout>
关于Android聊天应用-xml布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12529059/