我有一个 stacklayout,里面有三个标签。但是当我显示它时,这些标签之间存在差距。我想避开这个空间。任何人都可以帮助我哪个属性可以避免这个问题。
提前感谢您的帮助
最佳答案
使用 间距 的属性(property)堆栈布局调整项目之间的间距。
以下说明了这一点:-
StackLayout objStackLayout = new StackLayout()
{
Orientation = StackOrientation.Vertical,
Spacing = 0
};
Label objLabel1 = new Label();
objLabel1.BackgroundColor = Color.Red;
objLabel1.Text = "Red";
objStackLayout.Children.Add(objLabel1);
Label objLabel2 = new Label();
objLabel2.BackgroundColor = Color.Green;
objLabel2.Text = "Green";
objLabel2.Font = Font.OfSize("Arial", 48);
objStackLayout.Children.Add(objLabel2);
Label objLabel3 = new Label();
objLabel3.BackgroundColor = Color.Blue;
objLabel3.Text = "Blue";
objLabel3.Font = Font.OfSize("Arial", 48);
objStackLayout.Children.Add(objLabel3);
关于xamarin.forms - Stacklayout 标签间距 - Xamarin Forms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26012913/