Show Snack Bar with ScrollView

1

I hope you can help me, I have an activity with a tab, inside this tab 2 fragment, the second with the Scroll, since the data of this are several down, in the first I show the Snack bar with a message. the problem is that the Snack Bar is shown very low since it has all the scroll. That is, in the first tab it is not shown, but if I change to the second and low there is the message. How can I show the snack bar on the first tab in the lower section?

Below the xml code:

FRAGMENT 1

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinatorLayout">


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="20dp">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_dni"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp">

            <EditText
                android:id="@+id/input_dni"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_dni"
                android:inputType="number"
                android:maxLength="8"
                android:singleLine="true" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_contrasena"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp">

            <EditText
                android:id="@+id/input_contrasena"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_contrasena"
                android:inputType="numberPassword"
                android:maxLength="5" />
        </android.support.design.widget.TextInputLayout>

        <Button
            android:id="@+id/btnOlvidoSuContrasena"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="?android:attr/selectableItemBackground"
            android:text="@string/btn_olvido_su_contrasena"
            android:textColor="@android:color/black" />

        <Button
            android:id="@+id/btnIniciarSesion"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@color/primaryColor"
            android:text="@string/btn_iniciar_sesion"
            android:textColor="@android:color/white" />

        <!--<Button
            android:id="@+id/btn_or"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"

            android:background="?android:attr/selectableItemBackground"
            android:text="O"
            android:textColor="@android:color/black" />

        <Button
            android:id="@+id/btn_signup_google"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/primaryColor"
            android:text="Iniciar Sesión con google"
            android:textColor="@android:color/white" />

        <Button
            android:id="@+id/btn_signup_facebook"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@color/primaryColor"
            android:text="Iniciar Sesión con facebook"
            android:textColor="@android:color/white" />-->

        <ProgressBar
            android:id="@+id/progressBar_resetear_contrasena"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="center|bottom"
            android:layout_marginBottom="20dp"
            android:visibility="gone" />
    </LinearLayout>

FRAGMENT 2

<?xml version="1.0" encoding="utf-8"?>

android:padding="@dimen/md_keylines">

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:id="@+id/layout_grande"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="20dp">

        <!--  Nombres Label -->
        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_nombres"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/input_nombres"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_nombres"
                android:inputType="textCapWords"
                android:textAllCaps="true"/>
        </android.support.design.widget.TextInputLayout>

        <!--  Apellido Materno Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/input_apellido_paterno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_apellido_paterno"
                android:inputType="textCapWords"
                android:textAllCaps="true"/>
        </android.support.design.widget.TextInputLayout>

        <!--  Apellido Paterno Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/input_apellido_materno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_apellido_materno"
                android:inputType="textCapWords"
                android:textAllCaps="true"/>
        </android.support.design.widget.TextInputLayout>

        <!--  DNI Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/input_dni"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_dni"
                android:inputType="number"
                android:maxLength="8" />
        </android.support.design.widget.TextInputLayout>

        <!--  Email Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/input_correo_electronico"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_correo_electronico"
                android:inputType="textEmailAddress"
                android:textAllCaps="true"/>
        </android.support.design.widget.TextInputLayout>

        <!-- Password Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/input_contrasena"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/string_contrasena"
                android:inputType="numberPassword"
                android:maxLength="4" />
        </android.support.design.widget.TextInputLayout>

        <!-- Signup Button -->
        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btnRegistrarse"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="24dp"
            android:layout_marginTop="24dp"
            android:background="@color/primaryColor"
            android:text="@string/btn_crear_cuenta"
            android:textColor="@android:color/white" />

        <!--<TextView android:id="@+id/link_login"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="24dp"
            android:text="Already a member? Login"
            android:gravity="center"
            android:textSize="16dip"/>-->
    </LinearLayout>


</android.support.v4.widget.NestedScrollView>


<RelativeLayout
    android:id="@+id/layout_dot"
    android:layout_width="fill_parent"
    android:layout_height="70sp"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:visibility="invisible">

    <com.bhargavms.dotloader.DotLoader
        android:id="@+id/text_dot_loader"
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="50dp"
        android:layout_height="30dp"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true"
        android:layout_toRightOf="@+id/TextViewProgress"
        android:visibility="visible"
        app:color_array="@array/dot_colors"
        app:dot_radius="4dp"
        app:number_of_dots="3" />

    <TextView
        android:id="@+id/TextViewProgress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Registrando "
        android:textSize="44sp"
        android:textColor="@color/Orange_Resca"/>
</RelativeLayout>

3 TAB CONTAINER

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?attr/actionBarSize"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    style="@style/MyCustomTabLayout"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_gravity="bottom"
    android:background="?attr/colorPrimary"
    app:layout_anchor="@+id/appBarLayout"
    app:layout_anchorGravity="bottom"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/white"
    app:tabIndicatorHeight="4dp"
    app:tabMode="fixed" />

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="140dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <!-- <View
         android:layout_width="match_parent"
         android:layout_height="1dp"
         android:background="@color/white" />-->

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsingToolbarLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|enterAlways">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center"
            android:scaleType="centerInside"
            android:src="@drawable/iconogoogleplay" />

    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

The normal thing is that the snack is shown in the lower part of the screen but since the second tab has a scroll the snack goes to the last one and in the first tab it is not shown.

JAVA CODE WHEN CALLING THE SNACK

snackbar = Snackbar
                            .make(coordinatorLayout, getString(R.string.string_mensaje_de_sin_conexion), Snackbar.LENGTH_LONG);

                    View snackBarView = snackbar.getView();
                    snackBarView.setBackgroundColor(getResources().getColor(R.color.black));
                    TextView textView = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_text);
                    textView.setTextColor(getResources().getColor(R.color.white));

                    snackbar.show();

I hope you can help me. Thanks

    
asked by Kenny 21.09.2016 в 19:11
source

0 answers