How to make entry box's the same size?

Hello!
I was wondering how to make the boxes for my registry screen all the same size.
Things work fine unfortunately the boxs are only as large as their placeholders so not all the boxes are the same size horizontally.
It's not a huge issue but something i would like to fix.

Here is my code for the registry screen.

using System;
using System.Collections.Generic;
using System.Linq;
//using System.Reflection.Emit;
using System.Text;

using Xamarin.Forms;

namespace Pleasework
{
public class RegisterScreen : ContentPage
{
public RegisterScreen ()
{
Title = "Registry";
var usernameEntry = new Entry
{
Placeholder = "Username",
HorizontalOptions = LayoutOptions.CenterAndExpand
};
var firstNameEntry = new Entry
{
Placeholder = "First Name",
HorizontalOptions = LayoutOptions.CenterAndExpand
};
var lastNameEntry = new Entry
{
Placeholder = "Last Name",
HorizontalOptions = LayoutOptions.CenterAndExpand
};
var emailEntry = new Entry
{
Placeholder = "Email Address",
HorizontalOptions = LayoutOptions.CenterAndExpand
};
var passwordEntry = new Entry
{
Placeholder = "Password",
HorizontalOptions = LayoutOptions.CenterAndExpand
};
var reconfirmPasswordEntry = new Entry
{
Placeholder = "Re-Confirm Password",
HorizontalOptions = LayoutOptions.CenterAndExpand
};

        Padding = new Thickness(5, Device.OnPlatform(20, 5, 5), 5, 5);
        double fontsize = Device.GetNamedSize(NamedSize.Large, typeof(Label));


        Content = new StackLayout {
            Spacing = 5,
            VerticalOptions = LayoutOptions.FillAndExpand,

            Children = {
                new Label {
                    Text = "Please Fill In Information",
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    FontAttributes = FontAttributes.Bold
                },
                usernameEntry,
                firstNameEntry,
                lastNameEntry,
                emailEntry,
                passwordEntry,
                reconfirmPasswordEntry,

            }
        };
    }
}

}

Answers

  • Patil2421Patil2421 USMember ✭✭✭

    @GavWasTaken
    Give a try for LayoutOptions.FillAndExpand instead and use padding on main layout for the desired width of the controls, hopefully will work

Sign In or Register to comment.