对于简单的list控件已经有前辈分析了自带demo的ListRes全过程,duilib DirectUI库里面的一个简单的例子ListDemo,
他分析了listdemo的来龙去脉,这里我只是将个人理解的list分析一下。
由于自带的listdemo不能满足要求,所以必须个人扩展list,通过尝试 发现
1. 列表头禁止拖动情况
这种情况很简单, 配置xml的时候将 表头宽度 和 元素宽度设置相同就行了,listheader布局如下:
<List name="domainlist" bkcolor="#FFFFFFFF" inset="0,0,0,0" itemshowhtml="true" vscrollbar="true" hscrollbar="true" headerbkimage="file='list_header_bg.png'" itemalign="center" itembkcolor="#FFE2DDDF" itemaltbk="true" hscrollbar="false" menu="true">
<ListHeader height="24" menu="true">
<ListHeaderItem text="No" font="1" width="130" hotimage="file='list_header_hot.png'" pushedimage="file='list_header_pushed.png'" sepimage="file='list_header_sep.png'" sepwidth="1"/>
<ListHeaderItem text="Domain" font="1" width="160" hotimage="file='list_header_hot.png'" pushedimage="file='list_header_pushed.png'" sepimage="file='list_header_sep.png'" sepwidth="1"/>
<ListHeaderItem text="Description" font="1" width="140" hotimage="file='list_header_hot.png'" pushedimage="file='list_header_pushed.png'" sepimage="file='list_header_sep.png'" sepwidth="1"/>
</ListHeader>
</List>
上面是listdemo自带的xml,只是将listheaderitem宽度修改了
下面是listelement布局:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Window>

本文分析了duilib库中List控件的扩展方法,包括如何禁止列表头拖动以及实现列表头可拖动功能。通过修改XML配置和自定义SetPos函数,详细解释了控件布局原理,并提供了代码示例。
最低0.47元/天 解锁文章
564

被折叠的 条评论
为什么被折叠?



