Problem Toolbar and ScrollView Android

0

Good morning friends,

I have the following problem I hope someone can help me. I have a Toolbar and a ScrollView, what I want is that when having the focus on the EditText, the toolbar does not disappear from the screen in such a way that the user can press on the arrow of the Toolbar and return to the previous view although the EditText has the focus and the keyboard is enabled, this problem happens to me on a 240 x320 screen. I add my Layout and the image of the simulator

On the next image, the Toolbar disappears

 <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
       android:id="@+id/toolbar"
       layout="@layout/tool_bar" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/toolbar"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/txt_titulo"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="top|center_horizontal"
            android:hint="titulo"
            android:textColor="@android:color/white"
            android:textSize="23sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:theme="@style/LoginTextAppearance">

                <EditText
                    android:id="@+id/edt_email"
                    style="@style/loginEditTextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/d10dp"
                    android:hint="mi hint"
                    android:inputType="textEmailAddress" />
            </android.support.design.widget.TextInputLayout>

            <View
                android:id="@+id/view_divider"
                style="@style/separadorStyle" />
        </LinearLayout>


        <Button
            android:id="@+id/img_btn_sig"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_gravity="center"
            android:layout_marginTop="@dimen/d10dp"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:contentDescription="@string/boton_siguiente"
            android:text="Siguiente"
            />


        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:weightSum="10">

                <FrameLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="3.5">

                    <ImageView
                        android:layout_width="@dimen/d60dp"
                        android:layout_height="@dimen/d60dp"
                        android:layout_gravity="end|center_vertical"
                        android:layout_marginEnd="@dimen/d8dp"
                        android:layout_marginRight="@dimen/d8dp"

                        />

                </FrameLayout>

                <TextView
                    android:id="@+id/txt_msg_pie"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginTop="@dimen/d2dp"
                    android:layout_weight="6.5"
                    android:gravity="center_vertical"
                    android:text="Pie de Página"
                    android:textSize="@dimen/d10_5sp" />

            </LinearLayout>

        </FrameLayout>

    </LinearLayout>
</ScrollView>

Thank you in advance,

Greetings.

    
asked by Leo 16.02.2017 в 19:56
source

1 answer

0

If you want to keep your toolbar in view, you should use a CoordinatorLayout :

An example (look at app:layout_behavior="@string/appbar_scrolling_view_behavior" , which fixes the scroll theme):

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
        <android.support.v7.widget.Toolbar
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

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

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:ignore="MergeRootFrame" />


</android.support.design.widget.CoordinatorLayout>
    
answered by 16.02.2017 / 20:37
source