簡體   English   中英

更改每個屏幕尺寸的Xamarin表格的標簽大小

[英]Change label size per screen size xamarin forms

我正在使用xamarin.forms來做一個應用程序,但我發現使用相同的尺寸向ios設備發送字母是行不通的:在7以上的版本上效果很好,但在iphone 5上,它對於屏幕大小來說是一個大字母...有人知道用可調用的大小寫字母的方法,還是更改特定設備的大小或屏幕大小類型的方法? 非常感謝你。

您可以參考以下示例:

  1. 估計字體大小以保持視覺一致性-( 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; 
  2. 使文本適合可用大小-( docs | github

     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)); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM