Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何修复使用Kotlin单击editText时的NestedScrollView_Android_Kotlin_Android Nestedscrollview - Fatal编程技术网

Android 如何修复使用Kotlin单击editText时的NestedScrollView

Android 如何修复使用Kotlin单击editText时的NestedScrollView,android,kotlin,android-nestedscrollview,Android,Kotlin,Android Nestedscrollview,我有一个NestedScrollView,它包含很多组件,比如recyclerview、viewPager。。。 我有一个用于搜索的editText。还有一个包含搜索图标的应用程序栏。当我单击搜索图标时,editText会向下滑动,当我再次单击它时,会向下滑动。 我的问题是,当我向下滚动活动时,当我单击search editText时,该活动没有固定,向上移动并移出屏幕。 以下是主要的_activity.xml代码: <LinearLayout xmlns:android="ht

我有一个NestedScrollView,它包含很多组件,比如recyclerview、viewPager。。。 我有一个用于搜索的editText。还有一个包含搜索图标的应用程序栏。当我单击搜索图标时,editText会向下滑动,当我再次单击它时,会向下滑动。 我的问题是,当我向下滚动活动时,当我单击search editText时,该活动没有固定,向上移动并移出屏幕。 以下是主要的_activity.xml代码:

<LinearLayout 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:background="@color/grey"
        android:fitsSystemWindows="false"
        android:orientation="vertical">

    <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/whiteFour"
            android:paddingTop="@dimen/spacing_medium"
            android:paddingBottom="@dimen/spacing_medium"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/searchButtonMain"
                    android:layout_width="30dp"
                    android:layout_height="28dp"
                    android:layout_marginEnd="@dimen/spacing_middle"
                    android:adjustViewBounds="true"
                    android:tint="@color/black"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/Chart"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/ic_search" />
           <.....>


        </androidx.constraintlayout.widget.ConstraintLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <LinearLayout
            android:id="@+id/lytSearchView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/whiteFour"
            android:visibility="gone"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0">

        <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/searchFields"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="20dp"
                android:layout_marginBottom="10dp"
                android:background="@drawable/border"
                android:drawableStart="@drawable/icn_search_x"
                android:drawablePadding="@dimen/spacing_large"
                android:fontFamily="@font/cairo"
                android:gravity="left"
                android:hint="@string/search_product"
                android:inputType="text"
                android:lineHeight="18dp"
                android:maxLines="1"
                android:paddingStart="15dp"
                android:paddingTop="5dp"
                android:paddingEnd="15dp"
                android:paddingBottom="5dp"
                android:textColorHint="@color/greyish"
                android:textSize="14sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.0" />


    </LinearLayout>


    <androidx.core.widget.NestedScrollView
            android:id="@+id/nestedScrollView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/grey"
            android:clipToPadding="true"
            android:fillViewport="true"
            android:scrollbars="none"
            android:scrollingCache="true"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/appBarLayout">
<................> 

那么,当单击带有Kotlin的search editText时,我应该做些什么来修复NestedScrollView呢?您正在寻找的东西在活动标记的清单文件中被称为
android:WindowsOfInputMode
。尝试使用
adjustNothing
adjustPan
。我不确定你的预期行为是什么,但那就行了。不,我还是有同样的错误。当我在appBar中单击搜索图标时,编辑文本向下滑动,当编辑文本向下滑动,所有嵌套滚动视图向下移动,当我第二次单击搜索图标时,编辑文本向上滑动,所有嵌套滚动视图向上移动,我想修复嵌套滚动视图
 searchButtonMain.setOnClickListener {
            if (firstClickSearch) {
                val animation = AnimationUtils.loadAnimation(
                    this, R.anim.slide_up
                )
                 //appending animation to textView
                lytSearchView.startAnimation(animation)
                lytSearchView.visibility = View.GONE
                firstClickSearch = false
            } else {
                 val animation = AnimationUtils.loadAnimation(
                    this, R.anim.slide_down
                )

                //appending animation to textView
                lytSearchView.startAnimation(animation)
                lytSearchView.visibility = View.VISIBLE
                firstClickSearch = true
            }

      
        }