关于聊天内容,见得多了,就是一个列表,里面存着不同的人的聊天记录,自己的内容在一边,其它人的内容在另一边。列表没有看到分隔线,背景是白的或其它的,没有列表按下的效果。现在一个一个解决:列表背景android:background="" android:cacheColorHint=""这两个颜色设置成一样的,就可以了。如果选中的颜色也不要,可以自定义一个selector,设置成固定 的颜色 android:listSelector="#00000000" 这样。android:dividerHeight="0.0dip" 设置分隔线的高度为0,但是还可以看到一个分隔线。还需要一个设置android:divider="@null"就可以完全移除分隔线了。内容显示在左与右,最蠢的办法就是:if (orientation==1) {            ((LayoutInflater) mContext.getSystemService("layout_inflater")).inflate(R.layout.chat_left_item, this);            chat_txt_time=(TextView) findViewById(R.id.chat_txt_time);            chat_txt_msg=(TextView) findViewById(R.id.chat_txt_msg);            //content=(LinearLayout) findViewById(R.id.content);            nickname=(TextView) findViewById(R.id.chat_name);        } else {            ((LayoutInflater) mContext.getSystemService("layout_inflater")).inflate(R.layout.chat_right_item, this);            chat_txt_time=(TextView) findViewById(R.id.chat_txt_time);            chat_txt_msg=(TextView) findViewById(R.id.chat_txt_msg);            //content=(LinearLayout) findViewById(R.id.content);            nickname=(TextView) findViewById(R.id.chat_name);        }弄两个布局了,就可以解决了,但性能不高。可以动态的处理View元素的位置,比如一个ImageView作头像,一个TextView作文本,使用relativelayout,使用java动态的处理它们间的关系,也是可以的。relativelayout addRule可以添加规则,动态的添加子元素,这样至少不必每次都新建一个Layout,可以重复使用原来的。而上面的加载不同的布局,是不可以重用的,每次需要重新加载新的。



更多相关文章

  1. Python list sort方法的具体使用
  2. TextView设置跑马灯的样式
  3. Android(安卓)NDK
  4. android使用HttpClient和URLConnection获取网页内容
  5. 【Android】实现动态显示隐藏密码输入框的内容
  6. versionCode与versionName的区别、应用、获取
  7. 在android上使用cairo
  8. Android高手应该精通哪些内容?
  9. Android常用UI之AlertDialog

随机推荐

  1. android 决TextView中MaxLines与ellipsiz
  2. 解决国内android sdk无法更新,google不能
  3. A010-menu资源
  4. android 多语言的实现
  5. 【Android】数据存储之Shared Preference
  6. Android2.2 API 中文文档系列(9) ―― Zoom
  7. padding与margin的区别
  8. Android之3D物理引擎
  9. Android自定义view实现圆形waveview
  10. Android中项目中各个文件夹的含义和用途