一.android:singleLine
设置单行显示。如果和layout_width一起使用,当文本不能全部显示时,后面用“…”来表示。如
将只显示"t..."
如果不设置singleLine或者设置为false,文本将自动换行
二.android:cacheColorHint="@null"
cacheColorHint属性,很多人希望能够改变一下ListView的背景,使他能够符合整体的UI设计,改变背景背很简单只需要准备一张图片然后指定属性
- android:background="@drawable/bg"
不过不要高兴地太早,当你这么做以后,发现背景是变了,但是当你拖动,或者点击list空白位置的时候发现ListItem都变成黑色的了,破坏了整体效果。
如果你只是换背景的颜色的话,可以直接指定android:cacheColorHint为你所要的颜色,如果你是用图片做背景的话,那只要将android:cacheColorHint指定为透明(#00000000)就可以了
三.android:fadingEdge="@null"
上边和下边有黑色的阴影,
- android:fadingEdge="none"
设置后没有阴影了
四.android:divider="@null"
该属性作用是每一项之间需要设置一个图片做为间隔,或是去掉item之间的分割线
- android:divider="@drawable/list_driver"
其中 @drawable/list_driver 是一个图片资源,如果不想显示分割线则只要设置
- 为android:divider="@drawable/@null"
就可以了
五.android:listSelector="@android:color/transparent"当你不使用android:listSelector属性,默认会显示选中的item为橙黄底色,有时候我们需要去掉这种效果:进行上面的设置之后,ListView点击item时就没有任何现象了
- android:listSelector="#00000000"
六.android:transcriptMode="alwaysScroll"需要用ListView或者其它显示大量Items的控件实时跟踪或者查看信息,并且希望最新的条目可以自动滚动到可视范围内。通过设置的控件transcriptMode属性可以将Android平台的控件(支持ScrollBar)自动滑动到最底部。
- android:transcriptMode="alwaysScroll"<span></span>
七.android:scrollbars="none"作用是隐藏listView的滚动条,
- android:scrollbars="none"
与
- setVerticalScrollBarEnabled(true);
的效果是一样的,不活动的时候隐藏,活动的时候也隐藏
八.android:fadeScrollbars="true"配置ListView布局的时候,设置这个属性为true就可以实现滚动条的自动隐藏和显示。九.android:fastScrollEnabled="true"很多开发者不知道ListView列表控件的快速滚动滑块是如何启用的,其实辅助滚动滑块只需要一行代码就可以搞定,如果你使用XML布局只需要在ListView节点中加入这个属性即可,而对于Java代码可以通过
- android:fastScrollEnabled="true"
来控制启用,参数false为隐藏。 还有一点就是当你的滚动内容较小,不到当前ListView的3个屏幕高度时则不会出现这个快速滚动滑块,同时该方法仍然是AbsListView的基础方法,可以在ListView或GridView等子类中使用快速滚动辅助。
- myListView.setFastScrollEnabled(true);
十.android:drawSelectorOnTop
- android:drawSelectorOnTop="true"
<wbr style="FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important">点击某一条记录,颜色会显示在最上面,记录上的文字被遮住,所以点击文字不放,文字就看不到<div style="TEXT-ALIGN: left; BACKGROUND-COLOR: rgb(231,229,220); MARGIN: 18px 0px; WIDTH: 693px; FONT-FAMILY: Consolas, 'Courier New', Courier, mono, serif; FONT-SIZE: 12px; OVERFLOW: auto; PADDING-TOP: 1px" class="dp-highlighter bg_html"> <div style="PADDING-LEFT: 45px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important" class="bar"><div style="BORDER-LEFT: rgb(153,153,153) 3px solid; PADDING-BOTTOM: 10px; BACKGROUND-COLOR: rgb(248,248,248); PADDING-LEFT: 10px; PADDING-RIGHT: 8px; FONT: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; COLOR: silver; PADDING-TOP: 3px" class="tools"> <strong style="FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important">[html]</strong> <a target="_blank" style="BACKGROUND-IMAGE: none; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 10px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; COLOR: rgb(160,160,160); FONT-SIZE: 9px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; TEXT-DECORATION: none; PADDING-TOP: 0px" class="ViewSource" title="view plain" href="http://blog.csdn.net/jason0539/article/details/9849315#">view plain</a><a target="_blank" style="BACKGROUND-IMAGE: none; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 10px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; COLOR: rgb(160,160,160); FONT-SIZE: 9px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; TEXT-DECORATION: none; PADDING-TOP: 0px" class="CopyToClipboard" title="copy" href="http://blog.csdn.net/jason0539/article/details/9849315#">copy</a><a target="_blank" style="BACKGROUND-IMAGE: none; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 10px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; COLOR: rgb(160,160,160); FONT-SIZE: 9px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; TEXT-DECORATION: none; PADDING-TOP: 0px" class="PrintSource" title="print" href="http://blog.csdn.net/jason0539/article/details/9849315#">print</a><a target="_blank" style="BACKGROUND-IMAGE: none; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 10px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; COLOR: rgb(160,160,160); FONT-SIZE: 9px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; TEXT-DECORATION: none; PADDING-TOP: 0px" class="About" title="?" href="http://blog.csdn.net/jason0539/article/details/9849315#">?</a><div style="Z-INDEX: 99; POSITION: absolute; WIDTH: 28px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; HEIGHT: 17px; TOP: 3041px; LEFT: 570px"><embed style="FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important" id="ZeroClipboardMovie_13" height="17" name="ZeroClipboardMovie_13" type="application/x-shockwave-flash" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" width="28" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" wmode="transparent" flashvars="id=13&width=28&height=17" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false"></embed></div> </div></div> <ol style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: rgb(255,255,255); LIST-STYLE-TYPE: decimal; MARGIN: 0px 0px 1px 45px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; COLOR: rgb(92,92,92); BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px" class="dp-xml"><li style="LIST-STYLE-POSITION: outside; BORDER-BOTTOM-STYLE: none; BORDER-LEFT: rgb(153,153,153) 3px solid; PADDING-BOTTOM: 0px !important; LINE-HEIGHT: 18px; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: rgb(245,250,226); LIST-STYLE-TYPE: decimal-leading-zero; MARGIN: 0px; PADDING-LEFT: 10px !important; PADDING-RIGHT: 3px !important; FONT-FAMILY: 'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important; BORDER-TOP-STYLE: none; PADDING-TOP: 0px !important" class="alt"><span style="font-family:'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important;color:black;BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"><span class="attribute" style="font-family:'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important;color:red;BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px">android:drawSelectorOnTop</span><span style="font-family:'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important;color:black;BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px">=</span><span class="attribute-value" style="font-family:'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important;color:blue;BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px">"false"</span><span style="font-family:'WenQuanYi Micro Hei Mono', 'WenQuanYi Micro Hei', 'Microsoft Yahei Mono', 'Microsoft Yahei', sans-serif !important;color:black;BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"></span></span></li></ol> </div></wbr>
点击某条记录不放,颜色会在记录的后面,成为背景色,但是记录内容的文字是可见的