【问题标题】:Android BottomSheet with FloatButton带有 FloatButton 的 Android BottomSheet
【发布时间】:2016-03-01 16:09:53
【问题描述】:

如何使这种交互底部表和 FloatButton 像在谷歌地图中一样? 第一个屏幕截图显示了两个 FloatButtons。点击地图后,第二个按钮更改图标并向上滚动并钩在 bottomSheet 边缘。(屏幕截图2)。

First Screenshot

Second Screenshot

【问题讨论】:

    标签: android material-design floating-action-button android-support-design


    【解决方案1】:

    我认为 FAB 首先锚定到 MapViewright|bottom 并且与 BottomSheet 视图具有相同的高度。

    一旦BottomSheet窥视到某个高度并且BottomSheet顶部等于FAB高度的一半,那么一个新的锚ID附加到FABCoordinatorLayout.Params,基本上就是id@987654327 @视图。

    只是给你代码指针:

    CoordinatorLayout.Behavior behavior = (CoordinatorLayout.Behavior)fab.getLayoutParams();
    int boundary = fab.getTop() + (fab.getHeight() * 0.5);
    
    
    //inside `BottomSheet` callback methods
    if(sheetView.getTop() >= boundary){
       //sheet is expanding or its peeking height was changed
       behavior.setAnchorId(sheetView.getId());
    } else if (sheetView.getTop() <= boundary){
       //sheet is animating to collapse, being collapsed 
       behavior.setAnchorId(mapView.getId());
    }
    

    【讨论】:

      【解决方案2】:

      这是一个很好的参考,可以帮助您入门:

      How to implement BottomSheets

      Android Developer Blog on Bottom Sheets

      为了进一步帮助您,请发布现有代码以及您尝试过的内容。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-09
        • 1970-01-01
        • 1970-01-01
        • 2021-04-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多