Skip to content

Sneaker appear differently in activity and fragment #40

@kaancelen

Description

@kaancelen

Hi,

Sneaker appears differently from Activity and Fragment like below.
In Activity, it comes from the toolbar but in the fragment, it comes from the bottom of the toolbar.
The images are from different devices but it shows the same behavior with other devices as well.
I want both of them comes from the bottom of the toolbar as Fragment did.

Here is the AppTheme, its given in Android manifest and I didn't give any other theme to Activity.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/color_light_grey</item>
    <item name="colorPrimaryDark">@color/color_black</item>
    <item name="colorAccent">@color/color_red</item>

    <item name="android:windowContentTransitions">true</item>
</style>

Here how I show the error message, same code for both

protected fun showErrorMessage(errorMessage: String?, isGreen: Boolean = false) {
    val sneaker = Sneaker.with(this)
        .setDuration(4000)
        .autoHide(true)

    val view = LayoutInflater.from(this)
        .inflate(R.layout.view_sneaker_error, sneaker.getView(), false)

    if (isGreen) {
        view.setBackgroundColor(resources.getColor(R.color.color_green, null))
    }
    view.findViewById<TextView>(R.id.error_message).text = errorMessage

    sneaker.sneakCustom(view)
}

In Activity, FrameLayout at higher hierarchy
In Activity of Fragment,

<merge
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:filterTouchesWhenObscured="true"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"
        app:navGraph="@navigation/navigation_rent"/>

</merge>

and in Fragment, XML has also FrameLayout at higher hierarchy

Activity Screenshot
Activity
Fragment Screenshot
Fragment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions