2

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

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

聊天.xml

聊天

聊天.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>

气泡图:

在此处输入图像描述

4

1 回答 1

1

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

于 2012-04-09T18:16:26.537 回答