我正在做一个简单的聊天应用程序,并且想要显示类似于iphonesms app的气球。

所以我正在使用带有特定布局的ActivityListView
这是我的布局:

/* 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"气球就可以点击了。
  • 最佳答案

    FrameLayout是不必要的,因此请使用TextView作为根元素(当然,具有chat_ballon_left背景)。将宽度设置为match_parent,以使文本占据整个空间。

    顺便说一句,漂亮的气球,不要忘了也有hdpi版本:)

    10-08 07:50
    查看更多