function ItemTips.GetCustomShow(parent, data, isPetItem)
if not data or next(data) == nil then
return nil
end
if not parent then
return
end
local str = ""
local list = GUI:ListView_Create(parent, "Custom_list"
你的代码中横线长度不同的原因在于计算方式:
```lua
-- 第4项时添加的横线(你的代码)
if p == 4 and buff1 and buff2 then
local linePanel = ItemTips.CreateIntervalPanel(list, _DefaultSpace, true)
if linePanel then
local lineSize = GUI:getContentSize(linePanel)
listSize.height = listSize.height + lineSize.height + (_setVspace or 0)
listSize.width = math.max(listSize.width, lineSize.width) -- 这里只取当前横线宽度
end
end
-- 其他项的宽度计算(对比)
if isShowAttr then
local title = ItemTips.GetCustomTitleShow(p, list, d.t, d.c)
if title then
local titleSize = GUI:getContentSize(title)
listSize.height = listSize.height + titleSize.height + (_setVspace or 0)
listSize.width = math.max(listSize.width, titleSize.width) -- 这里取最大值
end
end
```
**问题分析:**
1. **你的横线计算时机不对**:只在`p == 4`时计算一次,且只取当前横线的宽度
2. **其他项的宽度是累计计算**:通过`math.max`取所有子项的最大宽度
3. **导致结果**:横线宽度只取自身宽度,而列表最终宽度取所有子项最大宽度,两者不一致
**解决方案:**
将横线的宽度计算也纳入累计逻辑,确保所有子项(包括横线)都参与最大宽度计算:
```lua
if p == 4 and buff1 and buff2 then
local linePanel = ItemTips.CreateIntervalPanel(list, _DefaultSpace, true)
if linePanel then
local lineSize = GUI:getContentSize(linePanel)
listSize.height = listSize.height + lineSize.height + (_setVspace or 0)
listSize.width = math.max(listSize.width, lineSize.width) -- 保持这个,但确保linePanel被正确添加到列表
-- 关键:需要将linePanel添加到ListView中
GUI:ListView_pushBackCustomItem(list, linePanel)
end
end
```
**检查点:**
1. 确保`ItemTips.CreateIntervalPanel`返回的面板宽度与列表内容区域匹配
2. 检查`_DefaultSpace`参数是否影响横线宽度
3. 确认横线面板是否设置了正确的内容尺寸
横线长短不同通常是因为横线面板的内容尺寸设置不正确,或者没有参与列表的整体布局计算。