roughike / BottomBar

(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.
Apache License 2.0
8.42k stars 1.5k forks source link

Elevation #827

Open hirosz opened 7 years ago

hirosz commented 7 years ago

Elevation attribute doesn't work

p-fischer commented 7 years ago

This might be related. I found a bug in the below code snippet.

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    private void init21(Context context) {
        if (showShadow) {
            shadowElevation = getElevation();
            shadowElevation = shadowElevation > 0
                    ? shadowElevation
                    : getResources().getDimensionPixelSize(R.dimen.bb_default_elevation);
            setElevation(MiscUtils.dpToPixel(context, shadowElevation));
            setOutlineProvider(ViewOutlineProvider.BOUNDS);
        }
    }

If getResources().getDimensionPixelSize(R.dimen.bb_default_elevation) is retrieved it is automatically resolved in pixels. But in setElevation(MiscUtils.dpToPixel(context, shadowElevation)); it the DP to PX convertion is applied a second time, which in most cases leads to a too high value.

My observation on Lollipop+ devices however is, that I cannot see any elevation shadow or just a tiny one. The shadow used to be much more significant in version 1.3.4.

mkaflowski commented 6 years ago

Elevation is always on for BottomBar. I do workaround by wrapping BottomBar with LinearLayout with elevation (background need to be set) and setting app:bb_showShadow="false".