aritraroy/Flashbar

Unwanted Bottom Margin on Oneplus Devices

ShivamArora opened this issue · 5 comments

There's an unwanted bottom margin added to the flashbar on Oneplus Devices.

I tested it out on emulator running on Pie and it works fine.

But on Oneplus 6 running on Pie it adds an unwanted bottom margin as you can see in this picture.

Screenshot of Unwanted Bottom Margin to Flashbar

I'm seeing the same problem on a Samsung Galaxy S10 using Flashbar 1.0.3.

image

encountered same issue using Huawei Nova 3i, fixed by removing lines 126-133 on this class FlashbarContainerView, hi @aritraroy please update the Repository :)

I have the same issue.
@charlest05 Hi dear, I have to clone and use that as module in the project ?

Same error

ykm17 commented

I got the Fix.
I had faced this issue on many MI devices. In internal fun adjustOrientation(activity: Activity) inside FlashbarContainerView.kt , I logged the navigationBarSize. Snackbar adds the bottom margin equal to the height of the navigation bar so that it doesn't overlap on the navigation bar. But activity.getNavigationBarSizeInPx() returns wrong size in many devices. Resulting in gap at the bottom or extra margin between the snack bar and navigation bar.
In function, I have changed the way how it retrieves navigation bar size and now it works fine. :)

internal fun adjustOrientation(activity: Activity) {
        val flashbarContainerViewLp = RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)

        var resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")

        val navigationBarPosition = activity.getNavigationBarPosition()
        var navigationBarSize = 0

        if (resourceId > 0) {
            navigationBarSize = resources.getDimensionPixelSize(resourceId);
        }

        when (navigationBarPosition) {
            LEFT -> flashbarContainerViewLp.leftMargin = navigationBarSize
            RIGHT -> flashbarContainerViewLp.rightMargin = navigationBarSize
            BOTTOM -> flashbarContainerViewLp.bottomMargin = navigationBarSize
        }
        layoutParams = flashbarContainerViewLp
    }