BottomBar icon indicating copy to clipboard operation
BottomBar copied to clipboard

how to use it in xml?

Open zhangzhzh opened this issue 10 years ago • 3 comments

How use it in activity_main.xml file rather than in MainActivity.java?

zhangzhzh avatar Mar 17 '16 01:03 zhangzhzh

I found it a bit awkward to use it directly by xml, as you would have to use a FrameLayout with two children (your main content and BottomBar with android:layout_gravity="bottom" set) to get started.

But I'll look into this.

roughike avatar Mar 17 '16 08:03 roughike

Another problem with inflating it from XML is that on tablets it won't behave properly. It should look like this but the BottomBar has no way to not overlap your content.

roughike avatar Mar 18 '16 00:03 roughike

So here's what I found about the XML issue:

  • A bit awkward to use it directly by xml, as you would have to use a RelativeLayout with two children, your main content with android:layout_above="@+id/bottomBar" and BottomBar with android:layout_alignParentBottom="true" set to get started.
  • Even after that it won't behave properly on tablets without extra configuration from the user (an extra layout in layout-sw600dp folder). It should look like this but the BottomBar has no way to not overlap content.

But you can add the BottomBar practically anywhere to your layout by using bottomBar.attach(findViewById(R.id.myView), savedInstanceState). This will let you control what View the BottomBar should contain. Basically with this you can put it anywhere in the View hierarchy.

Using the BottomBar should be as simple as possible and same code should work by default for both tablets and phones solution.

For these reasons, I'm closing this issue.

roughike avatar Mar 18 '16 03:03 roughike