using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 做成一个里面只装FrameLayout的列表型控件(它不会调整高度) /// public class VerticalFrameControl : VerticalScrolViewLayout { #region ■ 变量声明___________________________ /// /// 行之间的间距 /// public int rowSpace = 0; /// /// 桌布控件 /// private FrameLayout frameTable = null; #endregion #region ■ 初始化_____________________________ /// /// 做成一个列表型的FrameLayout(它不会调整高度) /// /// 行之间的间距(这个值是与行控件绑定一起使用的) public VerticalFrameControl(int i_rowSpace = 0) { rowSpace = Application.GetRealHeight(i_rowSpace); } /// /// 初始化桌布控件 /// private void InitFrameTable() { if (this.frameTable != null) { return; } this.frameTable = new FrameLayout(); this.frameTable.Width = this.Width; this.frameTable.Height = this.Height; this.AddChidren(this.frameTable); } #endregion #region ■ 添加子控件_________________________ /// /// 添加Frame子控件 /// /// public void AddChidrenFrame(FrameLayout frame) { //初始化桌布控件 this.InitFrameTable(); var child = this.frameTable.GetChildren(this.frameTable.ChildrenCount - 1); if (child != null) { frame.Y = child.Bottom + rowSpace; } this.frameTable.AddChidren(frame); //调整桌布高度 if (this.frameTable.Height < frame.Bottom) { this.frameTable.Height = frame.Bottom; } } #endregion #region ■ 一般方法___________________________ /// /// 调整子FrameLayout的高度 /// /// /// 底部空白间距(真实值) public void AdjustChidrenFrameHeight(FrameLayout frame, int buttomSpace) { var child = frame.GetChildren(frame.ChildrenCount - 1); if (child != null) { //调整桌布高度 if (frame.Height < child.Bottom + buttomSpace) { frame.Height = child.Bottom + buttomSpace; } } } /// /// 调整桌布高度 /// public void AdjustTableHeight() { var child = this.frameTable?.GetChildren(this.frameTable.ChildrenCount - 1); if (child != null) { //调整桌布高度 if (this.frameTable.Height < child.Bottom) { this.frameTable.Height = child.Bottom; } } } #endregion } }