首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有图片和文字的按钮,图片下面的文字,如何?

带有图片和文字的按钮,图片下面的文字,如何?
EN

Stack Overflow用户
提问于 2017-07-09 00:23:56
回答 1查看 5K关注 0票数 5

第一次使用xamarin的跨平台应用程序时,我正在使用visual studio 2017社区中的xamarin表单。

我有一个带有图像和文本的按钮,但文本需要在图像下面。当前文本显示在图像的左侧,我该如何操作?

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;

namespace AppUnap
{
public class PPrincipal : ContentPage
{
    public PPrincipal()
    {
        Button btn1= new Button();
        btn1.Image = "notas.png";
        btn1.Text = "Calificaciones";
        btn1.HorizontalOptions = LayoutOptions.CenterAndExpand;

        Button btn2 = new Button();
        btn2.Image = "notas.png";
        btn2.Text = "Aula Virtual";
        btn2.HorizontalOptions = LayoutOptions.CenterAndExpand;

        Content = new StackLayout
        {
            Spacing = 0,
            VerticalOptions = LayoutOptions.CenterAndExpand,
            Children =
            {
            new StackLayout
            {
                Spacing = 0,
                Orientation = StackOrientation.Horizontal,
                Children =
                {                       
                    btn1,
                    btn2,
                }
            }
            }


        };
    }
}
}
EN

回答 1

Stack Overflow用户

发布于 2017-07-09 02:54:10

你需要在你的按钮上使用ContentLayout。

下面是我在XAML中使用的代码:

代码语言:javascript
复制
<Button Command="{Binding MyCommand}" ContentLayout="Top,0" Text="mytext" Image="myimage.png" />

Top =图像的位置

0=图像和文本之间的间距

您应该可以很容易地了解如何在C#中使用ContentLayout

票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44988312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档