gxc
2019-10-29 081ea8d273048fd03756718ac6fb48a3c09218e9
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs
@@ -19,6 +19,10 @@
        /// 最大高度
        /// </summary>
        private int maxHeight = -1;
        /// <summary>
        /// 一个没什么用的东西
        /// </summary>
        private FrameLayout frameBackTemp = null;
        #endregion
@@ -78,24 +82,32 @@
        /// <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);
            }
        }