Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

c# - how do i make xamarin forms android app controls fit for different screen resolution

I'm building my first Xamarin android app. When I run it on API level 23 the controls all fit on the screen. When I run in on Oreo API level 27 some controls are not visible on the screen. When I deploy it on a device, I have to change display settings for smaller fonts for the controls to be visible on screen. Is there a way I can make the app auto size for different devices or screen resolutions? sample XAML code for one of the forms

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:controls="clr-namespace:kcsapapp"
             x:Class="kcsapapp.HomePage"
              xmlns:Controls="clr-namespace:kcsapapp"
             >
             
    <ContentPage.Content>
        <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
            <Label Text="Enter production information"
               />
            <Label Text="Start Date:" />
            <DatePicker x:Name="Stardate" Format="D"
                     DateSelected="Stardate_DateSelected" >
            
            </DatePicker >
            <Label Text="End Date:" />
            <DatePicker x:Name="Enddate" Format="D"                   
                     DateSelected="Enddate_DateSelected"   >
            </DatePicker>
            
            <Picker x:Name="picker"              
             Title="Select Ward"            
             SelectedIndexChanged="picker_SelectedIndexChanged" >             
            </Picker>
            
            <Picker x:Name="fpicker"              
             Title="Select Farmer"            
             SelectedIndexChanged="fpicker_SelectedIndexChanged" >

            </Picker>
            <controls:CustomLabel x:Name="vcname"
                HorizontalTextAlignment="Center"
                VerticalTextAlignment="Start"
                FontSize="14.5"            
                CurvedBackgroundColor="LightGreen"
                TextColor="White"               
                CurvedCornerRadius="15">

            </controls:CustomLabel>
            <Picker x:Name="iPicker" Title="Select primary VC indicator"
                   SelectedIndexChanged="iPicker_SelectedIndexChanged" >                
            </Picker>
            
            <Frame Style="{StaticResource FrameStyle}">
                <controls:CustomEntry x:Name="amount" Text="0"  Placeholder="Enter number" Keyboard="Numeric" Style="{StaticResource EntryStyle}"></controls:CustomEntry>
            </Frame>
            <Button x:Name="submitBtn"  BorderRadius="2" WidthRequest="100"  TextColor="White" BackgroundColor="{StaticResource LightGreenColor}" Text="Submit" Clicked="submitBtn_Clicked" >
            </Button>
        </StackLayout>
    </ContentPage.Content>
</ContentPage> ```

question from:https://stackoverflow.com/questions/65888934/how-do-i-make-xamarin-forms-android-app-controls-fit-for-different-screen-resolu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...