saulmm / CoordinatorBehaviorExample

2.71k stars 590 forks source link

Problem with EditText #20

Open cathirv opened 8 years ago

cathirv commented 8 years ago

Hi, I have a problem not as I fix, I have a EditText within the NestedScrollView, and when this element contains several lines, makes the action bar to collapse and then lose the focus of the EditText, as you fix it? Thanks in advance

This is my code

<RelativeLayout
    android:id="@+id/screen"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.cathi.speakout.libs.RippleEffect"
    android:descendantFocusability="beforeDescendants"
    android:background="#ffffff"
    android:focusableInTouchMode="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:ignore="RtlHardcoded">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/main.appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/main.collapsing"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

    <FrameLayout
        android:id="@+id/main.framelayout.title"
        android:layout_width="match_parent"
        android:layout_height="230dp"
        android:layout_gravity="bottom|center_horizontal"
        android:orientation="vertical"
        android:background="@drawable/background_lat"
        app:layout_collapseMode="parallax"
        app:layout_collapseParallaxMultiplier="0.3">

    <LinearLayout
        android:id="@+id/main.linearlayout.title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="bottom|end|right"
        android:layout_marginRight="30dp"
        android:layout_marginBottom="30dp"
        android:layout_gravity="bottom"
        android:layout_marginLeft="40dp">

        <TextView
            android:id="@+id/tituloContacto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="sans-serif"
            android:textStyle="bold"
            android:textSize="35sp"
            android:textColor="@android:color/white"
            android:text="@string/contact"
            android:gravity="right" />

        <TextView
            android:id="@+id/textInstrucciones"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="@string/fields"
            android:layout_marginTop="10dp"
            android:fontFamily="sans-serif"
            android:textStyle="italic"
            android:textSize="15sp"
            android:textColor="#99ffffff" />
        </LinearLayout>

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

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/linear_end"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        app:behavior_overlapTop="1dp"
        android:layout_marginBottom="58dp"
        android:background="#FFFFFF"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

    <LinearLayout
        android:id="@+id/linear_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="30dp"
        android:paddingRight="30dp"
        android:paddingBottom="20dp">

            <com.rengwuxian.materialedittext.MaterialEditText
                android:id="@+id/name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:textSize="17sp"
                android:hint="@string/name_contact"
                android:clickable="true"
                android:focusableInTouchMode="true"
                android:inputType="textPersonName"
                app:met_baseColor="@color/colorPrimaryDark"
                app:met_floatingLabel="highlight"
                app:met_primaryColor="@color/colorPrimary"/>

            <com.rengwuxian.materialedittext.MaterialEditText
                android:id="@+id/mail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="1dp"
                android:textSize="17sp"
                android:inputType="textEmailAddress"
                android:clickable="true"
                android:focusableInTouchMode="true"
                android:hint="@string/mail_contact"
                android:maxLength="50"
                app:met_baseColor="@color/colorPrimaryDark"
                app:met_floatingLabel="highlight"
                app:met_primaryColor="@color/colorPrimary"/>

            <com.rengwuxian.materialedittext.MaterialEditText
                android:id="@+id/message"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="1dp"
                android:textSize="17sp"
                android:inputType="textMultiLine"
                android:clickable="true"
                android:focusableInTouchMode="true"
                android:hint="@string/message_contact"
                app:met_baseColor="@color/colorPrimaryDark"
                app:met_floatingLabel="highlight"
                app:met_primaryColor="@color/colorPrimary"/>
   </LinearLayout>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#00000000"
        app:layout_anchor="@id/main.framelayout.title"
        app:theme="@style/ThemeOverlay.AppCompat.Dark"
        app:title="">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:gravity="right">

            <TextView
                android:id="@+id/main.textview.title"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:layout_gravity="right"
                android:text="Contacta con nosotros"
                android:layout_marginRight="30dp"
                android:textColor="@android:color/white"
                android:textSize="18sp" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="58dp"
        android:orientation="horizontal"
        android:layout_marginRight="6dp"
        android:gravity="right"
        android:background="#FFFFFF"
        android:layout_gravity="bottom"
        android:layout_alignParentBottom="true">

        <com.cathi.speakout.libs.RippleEffect
            android:id="@+id/accept"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginRight="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            app:rv_type="rectangle"
            app:rv_color="#cccccc"
            rv_centered="true">

            <CheckedTextView
                android:id="@+id/btnSend"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textColor="@color/colorPrimaryDark"
                android:fontFamily="sans-serif"
                android:textStyle="bold"
                android:paddingLeft="16dp"
                android:paddingRight="16dp"
                android:textSize="18sp"
                android:text="@string/send"
                android:layout_gravity="center"
                android:gravity="center_vertical"
                android:clickable="true" />
        </com.cathi.speakout.libs.RippleEffect>
    </LinearLayout>
    </android.support.design.widget.CoordinatorLayout>
</RelativeLayout>

3b13fc09-a37d-4da6-9cd2-3302f293ce0a