小编Sol*_*f93的帖子

隐藏和显示后不显示浮动操作按钮图标图像

嗨,我正在开发一个带有浮动操作按钮的 android 应用程序。

首次 FAB 图标显示图标图像。当我隐藏和显示图标图像后,当我单击 FAB 图标时,图标图像将为空白

这是用于隐藏 FAB 的代码

   mainScrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                // previousScrollY this variable is define in your Activity or Fragment
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Log.i(TAG, "onScrollChanged: scrollview position " + mainScrollView.getScrollY() + " " +
                                previousScrollY + " " +
                                mainScrollView.getChildAt(0).getHeight());
                        if (mainScrollView.getScrollY() > previousScrollY) {
                            fab.hide();
                        } else if (mainScrollView.getScrollY() < previousScrollY) {
                            fab.show();
                        }
                        if (mainScrollView.getScrollY() >= mainScrollView.getChildAt(0).getHeight()) {
                            previousScrollY = mainScrollView.getChildAt(0).getHeight();
                        } …
Run Code Online (Sandbox Code Playgroud)

java android floating-action-button

6
推荐指数
2
解决办法
2726
查看次数

脚手架底部导航栏重叠正文内容。如何预防

我想要一个带有应用栏和底部导航栏的仪表板。但是当我在 body(Scaffold) 中添加 listview 或 pageview 时,内容与底部导航栏重叠。

我已经设置了填充小部件和纵横比小部件,但内容高度因不同的屏幕尺寸而异。

BottomNavigationBar(
        backgroundColor: Colors.white,
        currentIndex: _currentIndex,

        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: [
          BottomNavigationBarItem(
            icon: new Icon(Icons.chat_bubble),
            title: new TextView(
              'Conversations',
              size: 16.0,
              color: Colors.black,
              fontWeight: FontWeight.normal,
            ),
          ),
          BottomNavigationBarItem(
            icon: new Icon(Icons.dashboard),
            title: new TextView(
              'Matchboard',
              size: 16.0,
              color: Colors.black,
              fontWeight: FontWeight.normal,
            ),
          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.person),
              title: TextView(
                'Match-o-Meter',
                size: 20.0,
                color: Colors.black,
                fontWeight: FontWeight.normal,
              ))
        ],
      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: IndexedStack(index: _currentIndex, …
Run Code Online (Sandbox Code Playgroud)

flutter

6
推荐指数
2
解决办法
3898
查看次数

标签 统计

android ×1

floating-action-button ×1

flutter ×1

java ×1