我有一个字体大小为14的文本。
在较小的屏幕上,它是可见的,但在较大的屏幕上变得更小。
我该怎么办呢?
在安卓系统上,我们有SP
可以根据不同的屏幕调整字体大小。
在Windows 8中是否有类似的功能呢?
我有一个字体大小为14的文本。
在较小的屏幕上,它是可见的,但在较大的屏幕上变得更小。
我该怎么办呢?
在安卓系统上,我们有SP
可以根据不同的屏幕调整字体大小。
在Windows 8中是否有类似的功能呢?
这将完全按照您的要求执行。
<Viewbox>
<TextBlock>Hello World</TextBlock>
</Viewbox>
我猜你正在使用XAML?
那么,你应该从这里开始:
<Page.Resources>
<x:Double x:Key="MyFontSize" />
<Style TargetType="TextBlock" x:Name="StandardText">
<Setter Property="FontSize" Value="{StaticResource MyFontSize}" />
</Style>
</Page.Resources>
<TextBlock Style="{StaticResource StandardText}">Hello World</TextBlock>
然后在你的代码后台加入类似这样的内容:
Double _FontSize;
if (Windows.UI.ViewManagement.ApplicationView.Value
== Windows.UI.ViewManagement.ApplicationViewState.FullScreenPortrait)
{
// based on portrait
if (this.RenderSize.Height > 2000)
_FontSize = 30;
if (this.RenderSize.Height > 1000)
_FontSize = 20;
else
_FontSize = 10;
}
else
{
// based on landscape
if (this.RenderSize.Height > 1500)
_FontSize = 30;
if (this.RenderSize.Height > 1000)
_FontSize = 20;
else
_FontSize = 10;
}
this.Resources["MyFontSize"] = _FontSize;
我正在研究这个问题。 我知道两件不同的事情。 一个是View Box,另一个是逻辑DPI。