Java xml中的聊天布局

Java xml中的聊天布局,java,android,xml,chat,Java,Android,Xml,Chat,如下图+xml代码所示,我在chatting.xml中创建了这个设计,然后我通过9-Patch创建了两个气泡图像,但我的问题是: 如何将这些气泡图像作为chatting.xml中聊天文本的背景,以及如何添加ListView是否重要 chating.xml chating.xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/re

如下图+xml代码所示,我在chatting.xml中创建了这个设计,然后我通过9-Patch创建了两个气泡图像,但我的问题是:

如何将这些气泡图像作为chatting.xml中聊天文本的背景,以及如何添加ListView是否重要

chating.xml

chating.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frameLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/MidnightBlue"
    android:padding="5dp" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="30dip"
            android:layout_weight=".99"
            android:background="@color/LightGray" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="TextView" />
        </ScrollView>

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:baselineAligned="true"
            android:orientation="horizontal"
            android:paddingBottom="0dp"
            android:paddingLeft="4dp"
            android:paddingRight="1dp" >

            <EditText
                android:id="@+id/textInput"
                android:layout_width="0dip"
                android:layout_height="40dp"
                android:layout_weight="1" />

            <Button
                android:id="@+id/btnSend"
                android:layout_width="80dp"
                android:layout_height="45dp"
                android:textColor="@color/MidnightBlue" 
                android:text="Send"
                />
        </LinearLayout>
    </LinearLayout>

</FrameLayout>

气泡图像:


在chatting.xml中为气泡创建新的图像视图。将其焦点设置为false,
android:focusable=“false”
您只希望在收到文本时显示气泡。
至于listview,是的,您需要一个,因为您希望能够格式化对话,为每条消息设置一个新行。在chating.xml中创建listview。列表视图应该会自动滚动,这样您就不需要滚动视图。

谢谢您的回答,但我试图拖放列表视图,但是我做不到!!!你能解释一下吗?谢谢:“用“”替换你的scrollview。你可能需要硬编码气泡图像,而不是使用xml小部件。用自定义适配器google custom listview adapter执行此操作。”