气球聊天应用程序问题

7

我正在制作一个简单的聊天应用程序,希望显示类似于的短信应用气球。

因此,我正在使用具有特定布局的ListViewActivity。 这是我的布局:

/* Activity Layout */ 
 <LinearLayout android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
    >

     <ListView android:id="@+id/chat_log"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:stackFromBottom="true"
         android:layout_marginTop="50dp"
         android:transcriptMode="alwaysScroll"
         android:layout_weight="1"
         android:cacheColorHint="#00000000"
         android:clickable="false"
     />

     <LinearLayout android:orientation="horizontal"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
     >

   <EditText android:id="@+id/chat_input_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:layout_gravity="bottom"
         />

         <Button android:id="@+id/chat_send_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/chat_send_button"
         />

     </LinearLayout>
 </LinearLayout>

其他:
/* Row Layout */
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/userprofile_view"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:background="@drawable/chat_ballon_left" >

 <TextView
  android:id="@+id/chat_message"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:paddingLeft="2dp"
  android:text="haasdasdasdasdasdasdasdoo" />
</FrameLayout>

这是result

我的问题:

  • 我想要移除灰色线条。
  • 文本没有充分利用空间。
  • 尽管我已经添加了android:clickable="false",但气球仍然可以点击。

使用以下代码修复了灰色分割线:android:divider="@android:color/transparent" - Macarse
尝试将文本对齐设置为左侧,您的图片看起来像是居中对齐了。 - Nathan Schwermann
@schwiz:实际上这是一个9patch的问题。在Android上使用它使得它看起来很酷。所以我不知道如何从ListView中的每一行中移除高亮显示。 - Macarse
解决了上一个问题,使用 android:listSelectorListView 中设置了选择器 :) - Macarse
1个回答

5
FrameLayout是不必要的,所以请使用TextView作为根元素(当然要使用chat_ballon_left背景)。将宽度设置为match_parent,使文本占据整个空间。
顺便说一下,气球很漂亮,请别忘了也提供hdpi版本 :)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接