2016-09-22 4 views
0

Iamはfloatlayoutを中心に手助けしましたか? 理解のためにアップロードされた画像... 私のアイデアは、アイコンを追加した後、KivyのWindows 8レトロなボタンをレトロなボタンで再現したレイアウトです。私はKivyの中心にFloatLayoutを配置することはできません

enter image description here

マイKVファイル:

<SMAgro>: 
    AnchorLayout: 
     anchor_x: 'center' 
     anchor_y: 'center' 
     FloatLayout: 
      canvas: 
       Color: 
        rgb: [1,1,1,1] 
       Rectangle: 
        pos: self.pos 
        size: self.size 
      Button: 
       background_color: [.4,1,.1,1] 
       pos_hint: {'x': 0.26, 'y': 0.328571} 
       size_hint: 0.45, 0.3 
       text: "Equipamentos" 
#    StackLayout: 
#     pos: self.parent.pos 
#     size: self.parent.size 
#     orientation: 'lr-tb' 
#     Image: 
#      source: 'kivy.png' 
#      size_hint_x: None 
#      width: 74 
#     Label: 
#      size_hint_x: None 
#      width: 100 
#      text: "Equipamentos" 

      Button: 
       background_color: [.4,1,.1,1] 
       pos_hint: {'x': 0.26, 'y': 0.15} 
       size_hint: 0.225, 0.18 
       text: 'Configuracoes' 
      Button: 
       background_color: [.4,1,.1,1] 
       pos_hint: {'x': 0.486, 'y': 0.15} 
       size_hint: 0.225, 0.18 
       text: 'Sobre' 

答えて

0

あなたはFloatLayoutサイズを設定し、例えばので、pos_hint: {'center_y': 0.5, 'center_x': 0.5}を追加することができます:あなたの最も広いボタンがsize_hint_x = 0.45を持っているとボタンがsize_hint_y = 0.18 + 0.3を持っています。容器の

サイズ:ボタンsize_hint: 1, 1を有する場合size_hint: 0.45, 0.48

次に、それは親コンテナ(FloatLayout)の100%の幅と高さだと、それは45%の幅とウィンドウの48%の高さに等しいです。

このコードが示すように、FloatLayout

FloatLayout: 
    pos_hint: {'center_y': 0.5, 'center_x': 0.5} 
    size_hint: 0.45, 0.48 
    canvas: 
     Color: 
      rgb: [1,1,1,1] 
     Rectangle: 
      pos: self.pos 
      size: self.size 
    Button: 
     background_color: [.4,1,.1,1] 
     pos_hint: {'x': 0, 'y': 0.375} 
     size_hint: 1, 0.625 
     text: "Equipamentos" 
    Button: 
     background_color: [.4,1,.1,1] 
     pos_hint: {'x': 0, 'y': 0} 
     size_hint: .5, 0.375 
     text: 'Configuracoes' 
    Button: 
     background_color: [.4,1,.1,1] 
     pos_hint: {'x': .5, 'y': 0} 
     size_hint: .5, 0.375 
     text: 'Sobre' 

centered FloatLayout

+0

仕事仲間中心IAM理解していない...私が試した... THANKS !!! –

+0

悪い説明を申し訳ありませんが、私の英語はあまり良くありません。主なものは、多くのものを中心に配置するよりも(この例では3つのボタン)1つのもの(この例ではFloatLayout) –

関連する問題