2017-01-05 2 views
1

1つのFloatingActionButtonインスタンスをコンテンツペインにバインドするとき、私は奇妙なグループ化効果に気付きました。コンテンツペインにバインドされた複数のFloatingActionButtonインスタンスの不規則な配置

最初のものを左下に、もう1つを右下に追加すると、それらは両方とも右にグループ化されます。

最初のものを右下に追加し、2番目を左下に追加すると、作成順に左にグループ化されます。

これは予期される動作ですが、なぜそれがバグですか?

ここでは、コードです:

public class FormMultipleFloatingButtons extends Form { 
    public FormMultipleFloatingButtons() { 
     this(true); 
    } 

    public FormMultipleFloatingButtons(boolean aLeftBeforeRight) { 
     setTitle("Button Placement"); 
     setScrollable(false); 
     Container contentPane = getContentPane(); 
     contentPane.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); 
     contentPane.setScrollableY(true); 
     Style style = contentPane.getAllStyles(); 
     style.setMarginUnit(Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS); 
     style.setMargin(5, 5, 5, 5); 
     style.setBorder(Border.createDashedBorder(1)); 
     TextArea textArea = new TextArea(
       "The placement of FloatingActionButtons when adding more than one of those.\n\n" 
       + "Tap the right toolbar button to recreate the form with swapped creation order " 
       + "of the two FloatingActionButton instances."); 
     textArea.setEditable(false); 
     contentPane.add(textArea); 
     Runnable runnableLeft =() -> { 
      FloatingActionButton floatingActionButton = FloatingActionButton.createFAB(
        FontImage2.MATERIAL_CALL_RECEIVED); 
      floatingActionButton.bindFabToContainer(contentPane, Component.LEFT, Component.BOTTOM); 
     }; 
     Runnable runnableRight =() -> { 
      FloatingActionButton floatingActionButton = FloatingActionButton.createFAB(
        FontImage2.MATERIAL_SUBDIRECTORY_ARROW_RIGHT); 
      floatingActionButton.bindFabToContainer(contentPane, Component.RIGHT, Component.BOTTOM); 
     }; 
     if (aLeftBeforeRight) { 
      runnableLeft.run(); 
      runnableRight.run(); 
     } else { 
      runnableRight.run(); 
      runnableLeft.run(); 
     } 
     getToolbar().addCommandToRightBar(new Command(
       "", 
       FontImage.createMaterial(FontImage.MATERIAL_SWAP_HORIZ, style)) { 
      @Override 
      public void actionPerformed(ActionEvent evt) { 
       FormMultipleFloatingButtons formMultipleFloatingButtons = new FormMultipleFloatingButtons(!aLeftBeforeRight); 
       formMultipleFloatingButtons.show(); 
      } 
     }); 
    } 
} 

答えて

0

コンテンツ・ペインが一つだけFloatingActionButtonをサポートしていますが。ファブをコンテンツペインに追加すると、階層化されたペインに配置され、それが2つのファブを追加する排他的なポジションであるため、衝突が発生します。

これは、FABのUXが単なる1つである必要があり、さらに多くの機能が必要な場合は、下に追加することができるため、私たちが設計したものではありません。

これを行う場合は、コンテンツペイン内でContainerを使用してバインドすることができます。

関連する問題