| | |
| | | /// 最大高度
|
| | | /// </summary>
|
| | | private int maxHeight = -1;
|
| | | /// <summary>
|
| | | /// 一个没什么用的东西
|
| | | /// </summary>
|
| | | private FrameLayout frameBackTemp = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <param name="addSpace">当真实高度超过原有高度时,是否添加空白</param>
|
| | | public void AdjustRealHeight(int bottomSpace, bool addSpace = true)
|
| | | {
|
| | | if (this.ChildrenCount == 0)
|
| | | int count = frameBackTemp == null ? this.ChildrenCount : this.ChildrenCount - 1;
|
| | | if (count <= 0)
|
| | | {
|
| | | frameBackTemp?.RemoveFromParent();
|
| | | frameBackTemp = null;
|
| | | //还原为最大高度
|
| | | this.Height = maxHeight;
|
| | | return;
|
| | | }
|
| | |
|
| | | //调整列表控件的高度
|
| | | var realHeight = this.ChildrenCount * this.GetChildren(0).Height + bottomSpace;
|
| | | var realHeight = count * this.GetChildren(0).Height + bottomSpace;
|
| | | if (realHeight < this.Height)
|
| | | {
|
| | | frameBackTemp?.RemoveFromParent();
|
| | | frameBackTemp = null;
|
| | | //缩小控件高度
|
| | | this.Height = realHeight;
|
| | | }
|
| | | else if (addSpace == true && bottomSpace > 0 && realHeight > this.maxHeight)
|
| | | {
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Height = bottomSpace;
|
| | | this.AddChidren(frameBack);
|
| | | frameBackTemp?.RemoveFromParent();
|
| | |
|
| | | frameBackTemp = new FrameLayout();
|
| | | frameBackTemp.Height = bottomSpace;
|
| | | this.AddChidren(frameBackTemp);
|
| | | }
|
| | | }
|
| | |
|