【问题标题】:Balloon chat application issues气球聊天应用程序问题
【发布时间】:2010-09-15 20:15:04
【问题描述】:

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

所以我正在使用具有特定布局的ListView 进行Activity。 这是我的布局:

/* 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"
  • 尝试将文本设置为左对齐,您的图片看起来像居中。
  • @schwiz:实际上这是 9patch 的问题。将一个用于 android 让它看起来很酷。所以我错过了如何从ListView 中的每一行中删除突出显示
  • 修复了我在ListView 中使用android:listSelector 设置选择器的上一个问题:)

标签: android android-layout


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-25
    • 1970-01-01
    • 2015-06-14
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 2013-02-05
    相关资源
    最近更新 更多