xamarin.forms - Stacklayout 标签间距 - Xamarin Forms

标签 xamarin.forms

我有一个 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/

相关文章:

c# - XAML 中框架的 System.InvalidCastException

xamarin - 如何修改 Xamarin.Forms 中的 WebView 以在设备上的浏览器中打开链接?

Xamarin 包安装错误

push-notification - Xamarin.Forms Azure 推送通知 - "MobileServiceInvalidOperationException: You do not have permission to view this directory or page"

c# - 从 Tap (TapGestureRecognizer) 事件中提取 byte[] 到 Xamarin Forms 中的 Click 事件

在 iOS 中使用自定义渲染器的按钮的 Xamarin.Forms 渐变背景

android - 如何从资源文件夹获取字体文件的路径以及如何使用该路径在xamarin android中设置SKTypeface?

c# - Xamarin.forms 中的 UITests 发布失败

xaml - Xamarin 表单 StackLayout : How to set width/height of children to percentages

c# - 如何序列化我的类(class)以通过 retrofit 将其作为 urlencoded 发送