Material Design:如何为Android Floating Action Button设置透明度

前端之家收集整理的这篇文章主要介绍了Material Design:如何为Android Floating Action Button设置透明度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我的问题与this有关.

当我打开NavigationDrawer时,浮动按钮位于其顶部,但必须位于下方.

我尝试这样做:

        @Override
        public void onDrawerSlide(View drawerView,float slideOffset) {
            Log.i(TAG," inner onDrawerSlide");
            super.onDrawerSlide(drawerView,slideOffset);
            fabButton.setAlpha(25);
            float alpha = 0.2f;
            AlphaAnimation alphaUp = new AlphaAnimation(alpha,alpha);
            alphaUp.setFillAfter(true);
            fabButton.startAnimation(alphaUp);
            syncState();
        }

和那样:

            @Override
            public void onDrawerSlide(View drawerView,float slideOffset) {
                super.onDrawerClosed(view);
                invalidateOptionsMenu();
                fabButton.setAlpha(255);
                syncState();
            }

没有什么对我有用.什么可以解决方案?

我的布局:

FragmentNavigationDrawer是自定义的DrawerLayout

最佳答案
来自Android documentation for setAlpha(float alpha)(自API 11起):

Sets the opacity of the view. This is a value from 0 to 1,where 0
means the view is completely transparent and 1 means the view is
completely opaque.

你试图将它设置为值25或255 原文链接:https://www.f2er.com/android/431248.html

猜你在找的Android相关文章