2016-09-07 8 views
0

Ich versuche eine Schnittstelle mit der KV-Sprache zu erstellen, die vom Kivy-Framework bereitgestellt wird. Ich möchte zwei BoxLayout Widgets übereinander stapeln. Wenn das erste Layout gerendert wird, hat es eine Standardhöhe von 350. Ich muss dies sonst reduzieren.Kivy-Layout wird nicht wie erwartet gerendert

Unten ist mein Layout

<RootWidget>: 
# this is the rule for your root widget, defining it's look and feel. 
StackLayout: 
    height: 350.0 
    BoxLayout: 
     id: 'letterBox' 
     height: 150.0 
     ActionButton: 
      width: 15.0 
      text: '-' 
     ActionButton: 
      width: 15.0 
      text: 'A' 
     ActionButton: 
      width: 15.0 
      text: 'B' 
     ActionButton: 
      width: 15.0 
      text: 'C' 
     ActionButton: 
      width: 15.0 
      text: 'D' 
     ActionButton: 
      width: 15.0 
      text: 'E' 
     ActionButton: 
      width: 15.0 
      text: 'F' 
     ActionButton: 
      width: 15.0 
      text: 'G' 
     ActionButton: 
      width: 15.0 
      text: 'H' 
     ActionButton: 
      width: 15.0 
      text: 'I' 
     ActionButton: 
      width: 15.0 
      text: 'J' 
     ActionButton: 
      width: 15.0 
      text: 'K' 
     ActionButton: 
      width: 15.0 
      text: 'L' 
     ActionButton: 
      width: 15.0 
      text: 'M' 
     ActionButton: 
      width: 15.0 
      text: 'N' 
     ActionButton: 
      width: 15.0 
      text: 'O' 
     ActionButton: 
      width: 15.0 
      text: 'P' 
     ActionButton: 
      width: 15.0 
      text: 'Q' 
     ActionButton: 
      width: 15.0 
      text: 'R' 
     ActionButton: 
      width: 15.0 
      text: 'S' 
     ActionButton: 
      width: 15.0 
      text: 'T' 
     ActionButton: 
      width: 15.0 
      text: 'U' 
     ActionButton: 
      width: 15.0 
      text: 'V' 
     ActionButton: 
      width: 15.0 
      text: 'W' 
     ActionButton: 
      width: 15.0 
      text: 'X' 
     ActionButton: 
      width: 15.0 
      text: 'Y' 
     ActionButton: 
      width: 15.0 
      text: 'Z' 
    BoxLayout: 
     id: 'contentBox' 
     height: 150.0 
     ActionButton: 
      text: '4' 

Antwort

1

Sie tun könnte. Versuchen Sie es mit size_hint, da es Ihre App anspricht und in allen Bildschirmauflösungen gleich aussieht.

BoxLayout: 
    orientation: 'vertical' 
     BoxLayout: 
      id: 'letterBox' 
      size_hint: 1, .15 

     BoxLayout: 
      id: 'contentBox' 
      size_hint: 1, .85 
+0

Wow, das Attribut size_hint hat mein Leben verändert. Ich habe mich gefragt, wie die relativen Größen funktionieren. –