ListView属性分析:
<ListView
android:id="@+id/lv_chat_message"
android:layout_width="fill_parent"
android:layout_height=“wrap_content"
|滑动不改变背景
android:listSelector="#00000000"
android:cacheColorHint="#00000000”
|聊天界面时随软键盘弹出变动(待定,不用也可以?)
android:transcriptMode=“alwaysScroll"
|去掉两端的模糊区和渐变色
android:overScrollMode="never"
android:fadingEdge=“none"
|默认滚动到数据的最下端(不好用)
android:stackFromBottom=“true”
|不显示右侧滚动条,用于聊天布局时,一定不要加这个,否则当软键盘弹出时。会把头布局也顶上去
android:scrollbars="none"
|不显示分割线
android:divider="@null"
>
</ListView>
仿聊天界面,默认显示到数据的底部:
mChatListView.setSelection(mDatas.size()-1);
ListView设置不能滚动:
1:ListView.setEnable(false);
ListView更改点击的背景色:
在填充数据的adapter的布局文件中加backgroud属性
android:background="@drawable/group_item_selector"
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@color/group_item_pressed"/>
<item android:state_pressed="true" android:drawable="@color/group_item_pressed"/>
<item android:state_pressed="false" android:state_focused="false" android:drawable="@color/white"/>
</selector>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@color/group_item_pressed"/>
<item android:state_pressed="true" android:drawable="@color/group_item_pressed"/>
<item android:state_pressed="false" android:state_focused="false" android:drawable="@color/white"/>
</selector>