【问题标题】:Differences between emulator layout and phone layout模拟器布局和手机布局的区别
【发布时间】:2015-04-13 03:01:30
【问题描述】:

我有一个问题,因为我不明白为什么当我在手机上运行我的应用程序时,它的布局会有所不同。按钮向右移动了一点。链接截图:

在模拟器上看起来正确,项目居中。我正在使用 Visual Studio Express。

<Page
x:Class="App6.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App6"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid HorizontalAlignment="Right" Margin="0,0.333,0,-0.333" Width="400">
    <Grid.RowDefinitions>
        <RowDefinition Height="59*"/>
        <RowDefinition Height="625*"/>
    </Grid.RowDefinitions>
    <Button Content="Kliknij" HorizontalAlignment="Center"   Click="Button_Click" RenderTransformOrigin="0.585,-5.095" Margin="146,499.253,145,69" Grid.Row="1"  />
    <TextBlock x:Name="costam" Margin="96,202.253,102,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" FontSize="36" HorizontalAlignment="Center" Width="202" Text="kj." Grid.Row="1"/>
    <Button x:Name="schowaj" Content="Schowaj" HorizontalAlignment="Left" Margin="139,410.253,0,0" VerticalAlignment="Top" Click="schowaj_Click" Grid.Row="1"/>
    <TextBox x:Name="wpisz" HorizontalAlignment="Left" Margin="139,297.253,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="109" Grid.Row="1"/>
    <Button x:Name="zamien" Content="Zamień" HorizontalAlignment="Left" Margin="139,351.253,0,0" VerticalAlignment="Top" Click="zamien_Click" Grid.Row="1"/>

</Grid>

【问题讨论】:

  • 你能发布 XAML 代码吗?
  • 没问题。我已经发布了代码
  • 你想做什么?能给个模拟器屏幕截图吗?
  • 我希望它看起来像这样(最低的按钮居中):link
  • 如果不是真的需要,不要使用硬编码的边距。如果你想要一些居中的东西,那么使用 Horizo​​ntalAlignment = center,也可以在需要时利用列和行。这将帮助您定位元素,而不管屏幕大小。

标签: xaml windows-phone-8.1


【解决方案1】:

您使用的模拟器可能与您的设备具有不同的分辨率或屏幕尺寸。主要问题是您使用边距来定位元素,这是完全错误的,并且取决于分辨率/屏幕尺寸。只需我们一个 Grid 并将其分成几行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    • 1970-01-01
    相关资源
    最近更新 更多