Joy*_*nna 5 c# layout xaml xamarin xamarin.forms
我正在使用xamarin.forms来做一个应用程序我觉得使用相同的大小来写信给ios设备是行不通的:在7加上它运行良好,但在iPhone 5上它是一个大字母的屏幕大小...有人知道如何使用可伸缩大小的字母,或更改特定设备或屏幕大小类型的大小?非常感谢你.
您可以参考以下样本:
估计字体大小以获得视觉一致性 - (docs | github)
// Resolution in device-independent units per inch.
double resolution = 160;
// Do some numeric point sizes.
int[] ptSizes = { 4, 6, 8, 10, 12 };
// Select numeric point size you need from ptSize[] array
double ptSize = 4;
// this is your new visually consistent font-size.
var fontSize = resolution * ptSize / 72;
Run Code Online (Sandbox Code Playgroud)double lineHeight = Device.OnPlatform(1.2, 1.2, 1.3);//TODO: Change this to Device.RuntimePlatform
double charWidth = 0.5;
int charCount = text.Length;
var view = this.Parent;
// Because:
// lineCount = view.Height / (lineHeight * fontSize)
// charsPerLine = view.Width / (charWidth * fontSize)
// charCount = lineCount * charsPerLine
// Hence, solving for fontSize:
int fontSize = (int)Math.Sqrt(view.Width * view.Height /
(charCount * lineHeight * charWidth));
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
3506 次 |
| 最近记录: |