XAMARIN: cross-Plattform FontFamily

Muss ich angeben, verschiedene FontFamily für verschiedene Labels in meiner app. Ich muss verwenden Sie die Standard-Schriftarten (z.B. Roboto für Android und Helvetica für iOS) mit Ihren änderungen (z.B. Light, Medium, Bold). Soweit ich das verstanden habe sollte ich mit Roboto-Light und Helvetica-Licht, um die Light-version der Schriften (gleich für Medium und Bold).
Zusätzlich zu dieser Bedingung muss ich zum einstellen der Schriftarten in XAML (wie beschrieben in der Dokumentation) so Ende ich mit diesem code

<StackLayout BackgroundColor="#F8F8F8" Padding="0, 20, 0, 0">
<Label Text="Black" TextColor="#000000" >
  <Label.FontSize>
    <OnPlatform x:TypeArguments="x:Double"
                iOS="17"
                Android="16"
                WinPhone="16" />
  </Label.FontSize>
  <Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
      <OnPlatform.iOS>Helvetica-Black</OnPlatform.iOS>
      <OnPlatform.Android>Roboto-Black</OnPlatform.Android>
      <OnPlatform.WinPhone></OnPlatform.WinPhone>
    </OnPlatform>
  </Label.FontFamily>
</Label>
<Label Text="Light" TextColor="#000000">
  <Label.FontSize>
    <OnPlatform x:TypeArguments="x:Double"
                iOS="17"
                Android="16"
                WinPhone="16" />
  </Label.FontSize>
  <Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
      <OnPlatform.iOS>Helvetica-Light</OnPlatform.iOS>
      <OnPlatform.Android>Roboto-Light</OnPlatform.Android>
      <OnPlatform.WinPhone></OnPlatform.WinPhone>
    </OnPlatform>
  </Label.FontFamily>
</Label>
<Label Text="Medium" TextColor="#000000" >
  <Label.FontSize>
    <OnPlatform x:TypeArguments="x:Double"
                iOS="17"
                Android="16"
                WinPhone="16" />
  </Label.FontSize>
  <Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
      <OnPlatform.iOS>Helvetica-Medium</OnPlatform.iOS>
      <OnPlatform.Android>Roboto-Medium</OnPlatform.Android>
      <OnPlatform.WinPhone></OnPlatform.WinPhone>
    </OnPlatform>
  </Label.FontFamily>
</Label>
<Label Text="Bold"  TextColor="#000000">
  <Label.FontSize>
    <OnPlatform x:TypeArguments="x:Double"
                iOS="17"
                Android="16"
                WinPhone="16" />
  </Label.FontSize>
  <Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
      <OnPlatform.iOS>Helvetica-Bold</OnPlatform.iOS>
      <OnPlatform.Android>Roboto-Bold</OnPlatform.Android>
      <OnPlatform.WinPhone></OnPlatform.WinPhone>
    </OnPlatform>
  </Label.FontFamily>
</Label>

Jedoch, das Ergebnis in Android ist unerwartet. Die FontFamily der verschiedenen Labels ist nicht geändert. Sie sehen alle gleich aus.

XAMARIN: cross-Plattform FontFamily

Den gleichen code in iOS funktioniert wie erwartet

XAMARIN: cross-Plattform FontFamily

Meine Frage ist: Wie bekommt man die Roboto-Light, Roboto-Medium und Roboto-Bold Schriften in meine Android-app, wenn folgende XAMARIN-Dokumentation nicht arbeiten?

InformationsquelleAutor Pavel Pavlov | 2015-09-23

Schreibe einen Kommentar