androidnavigation-drawerandroid-scrollviewbringtofront

What's the difference between bringToFront in Android 4 and Android 5?


I've got this layout with a DrawerLayout and a ScrollView:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".InformacionTienda">

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="260dp"
    android:layout_height="match_parent"
    android:layout_marginTop="70dp">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="10dp"
        android:paddingRight="10dp">

        <android.support.v7.widget.CardView
            android:id="@+id/quienesSomosCv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/quienesSomosCabecera"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="#010001"
                    android:text="¿Quiénes somos?"
                    android:textColor="#fffcf7"
                    android:textSize="@dimen/tamano_localizacion" />

                <TextView
                    android:id="@+id/quienesSomosTexto"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/quienesSomosCabecera"
                    android:layout_centerHorizontal="true"
                    android:paddingTop="5dp"
                    android:text="test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test " />
            </RelativeLayout>
        </android.support.v7.widget.CardView>


        <android.support.v7.widget.CardView
            android:id="@+id/mapaCv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/localizacionCabecera"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="#010001"
                    android:text="Localización"
                    android:textColor="#fffcf7"
                    android:textSize="@dimen/tamano_localizacion" />

                <ImageView
                    android:id="@+id/mapa"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/tamano_mapa"
                    android:layout_below="@+id/localizacionCabecera"
                    android:layout_centerHorizontal="true"
                    android:scaleType="centerCrop"
                    android:src="@drawable/empresa_icon" />

            </RelativeLayout>
        </android.support.v7.widget.CardView>


        <android.support.v7.widget.CardView
            android:id="@+id/contactoCv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/contactoCabecera"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="#010001"
                    android:text="Contacto"
                    android:textColor="#fffcf7"
                    android:textSize="@dimen/tamano_localizacion" />

                <TextView
                    android:id="@+id/telefono"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/contactoCabecera"
                    android:paddingTop="5dp"
                    android:text="Telefono: 666 666 666" />

                <ImageButton
                    android:id="@+id/botonLlamar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignEnd="@+id/telefono"
                    android:layout_alignRight="@+id/telefono"
                    android:background="@drawable/ic_launcher" />

                <ImageButton
                    android:id="@+id/botonMail"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignEnd="@+id/telefono"
                    android:layout_alignRight="@+id/telefono"
                    android:layout_below="@+id/botonLlamar"
                    android:background="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/calle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/telefono"
                    android:paddingTop="5dp"
                    android:text="Calle: El 742 de Evergreen Terrace" />

                <TextView
                    android:id="@+id/facebook"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/calle"
                    android:autoLink="web"
                    android:paddingTop="5dp"
                    android:text="www.facebook.com" />

                <TextView
                    android:id="@+id/mail"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/facebook"
                    android:autoLink="email"
                    android:paddingTop="5dp"
                    android:text="email@email.com" />

            </RelativeLayout>

        </android.support.v7.widget.CardView>
    </LinearLayout>
</ScrollView>
<!-- Contenido de la actividad -->
<include layout="@layout/content_layout" />
<!-- Navigation Drawer Layout -->
<include layout="@layout/navdrawer_layout" />

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

Anyone knows why it's look like this in Android 4? (and works perfectly): http://snag.gy/DKgk9.jpg

And why looks like in Android 5? http://snag.gy/WjVXh.jpg

bringChildToFront function does the same.


Solution

  • I've got the solution!

    I only need to put a LinearLayout as father of the scrollView:

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".InformacionTienda">
    
    <LinearLayout
        android:id="@+id/testlayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="70dp"
        android:paddingTop="70dp">
    
        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="10dp"
                android:paddingRight="10dp">
    
                <android.support.v7.widget.CardView
                    android:id="@+id/quienesSomosCv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
    
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
    
                        <TextView
                            android:id="@+id/quienesSomosCabecera"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentLeft="true"
                            android:background="#010001"
                            android:text="¿Quiénes somos?"
                            android:textColor="#fffcf7"
                            android:textSize="@dimen/tamano_localizacion" />
    
                        <TextView
                            android:id="@+id/quienesSomosTexto"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/quienesSomosCabecera"
                            android:layout_centerHorizontal="true"
                            android:paddingTop="5dp"
                            android:text="test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test " />
                    </RelativeLayout>
                </android.support.v7.widget.CardView>
    
    
                <android.support.v7.widget.CardView
                    android:id="@+id/mapaCv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
    
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
    
                        <TextView
                            android:id="@+id/localizacionCabecera"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentLeft="true"
                            android:background="#010001"
                            android:text="Localización"
                            android:textColor="#fffcf7"
                            android:textSize="@dimen/tamano_localizacion" />
    
                        <ImageView
                            android:id="@+id/mapa"
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/tamano_mapa"
                            android:layout_below="@+id/localizacionCabecera"
                            android:layout_centerHorizontal="true"
                            android:scaleType="centerCrop"
                            android:src="@drawable/empresa_icon" />
    
                    </RelativeLayout>
                </android.support.v7.widget.CardView>
    
    
                <android.support.v7.widget.CardView
                    android:id="@+id/contactoCv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
    
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
    
                        <TextView
                            android:id="@+id/contactoCabecera"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentLeft="true"
                            android:background="#010001"
                            android:text="Contacto"
                            android:textColor="#fffcf7"
                            android:textSize="@dimen/tamano_localizacion" />
    
                        <TextView
                            android:id="@+id/telefono"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/contactoCabecera"
                            android:paddingTop="5dp"
                            android:text="Telefono: 666 666 666" />
    
                        <ImageButton
                            android:id="@+id/botonLlamar"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignEnd="@+id/telefono"
                            android:layout_alignRight="@+id/telefono"
                            android:background="@drawable/ic_launcher" />
    
                        <ImageButton
                            android:id="@+id/botonMail"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignEnd="@+id/telefono"
                            android:layout_alignRight="@+id/telefono"
                            android:layout_below="@+id/botonLlamar"
                            android:background="@drawable/ic_launcher" />
    
                        <TextView
                            android:id="@+id/calle"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/telefono"
                            android:paddingTop="5dp"
                            android:text="Calle: El 742 de Evergreen Terrace" />
    
                        <TextView
                            android:id="@+id/facebook"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/calle"
                            android:autoLink="web"
                            android:paddingTop="5dp"
                            android:text="www.facebook.com" />
    
                        <TextView
                            android:id="@+id/mail"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/facebook"
                            android:autoLink="email"
                            android:paddingTop="5dp"
                            android:text="email@email.com" />
    
                    </RelativeLayout>
    
                </android.support.v7.widget.CardView>
            </LinearLayout>
        </ScrollView>
    </LinearLayout>
    <!-- Contenido de la actividad -->
    <include layout="@layout/content_layout" />
    <!-- Navigation Drawer Layout -->
    <include layout="@layout/navdrawer_layout" />
    

    Many thanks!