Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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 当选择微调器项目时,如何阻止ScrollView向上滚动?_Android_User Interface_Scrollview_Android Xml_Android Scrollview - Fatal编程技术网

Android 当选择微调器项目时,如何阻止ScrollView向上滚动?

Android 当选择微调器项目时,如何阻止ScrollView向上滚动?,android,user-interface,scrollview,android-xml,android-scrollview,Android,User Interface,Scrollview,Android Xml,Android Scrollview,我的ScrollView中有一堆EditText、TextView、微调器和其他组件,现在发生的是,当我从任何微调器中选择一个项目时,ScrollView自动向上滚动,第一个EditText获得焦点 如何防止这些其他视图获得焦点和滚动视图向上滚动 我已经尝试过android:DegenantFocusability=“BeforeDegenders”,但它不起作用“adjustPan”也不起作用 请帮忙 这是我的xml代码 <?xml version="1.0" encoding="utf

我的ScrollView中有一堆EditText、TextView、微调器和其他组件,现在发生的是,当我从任何微调器中选择一个项目时,ScrollView自动向上滚动,第一个EditText获得焦点

如何防止这些其他视图获得焦点和滚动视图向上滚动

我已经尝试过android:DegenantFocusability=“BeforeDegenders”,但它不起作用
“adjustPan”
也不起作用

请帮忙

这是我的xml代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/screen_background"
    android:orientation="vertical">

    <include
        layout="@layout/appbar_registration"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></include>

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

        <LinearLayout
            android:id="@+id/linear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:gravity="center"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="SIGN UP"
                android:textColor="@color/background_color"
                android:textSize="30sp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Create an account"
                android:textColor="@color/registration_text_gray" />
        </LinearLayout>

        <ScrollView
            android:id="@+id/scrollview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/buttonlinear"
            android:layout_below="@+id/linear"
            android:layout_marginBottom="15dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:fillViewport="true"
            android:scrollbars="none">

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"
                        android:hint="Name"
                        android:inputType="textCapWords"
                        android:lines="1"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_father_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"
                        android:hint="Father's Name"
                        android:inputType="textCapWords"
                        android:lines="1"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:orientation="horizontal"
                    android:weightSum="10">

                    <Spinner
                        android:id="@+id/registration_spnr_country"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="9.5"
                        android:background="@android:color/transparent" />

                    <ImageView
                        android:id="@+id/registration_img_country"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight="0.5"

                        android:src="@drawable/ic_spinner_arrow" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:orientation="horizontal"
                    android:weightSum="10">

                    <Spinner
                        android:id="@+id/registration_spnr_state"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="9.5"
                        android:background="@android:color/transparent"
                        android:clickable="false" />

                    <ImageView
                        android:id="@+id/registration_img_state"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight="0.5"
                        android:clickable="false"
                        android:src="@drawable/ic_spinner_arrow" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_district"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:hint="District"
                        android:inputType="textCapWords"
                        android:lines="1"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_city_village"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:hint="City / Village"
                        android:inputType="textCapWords"
                        android:lines="1"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_mobile"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:hint="Mobile"
                        android:inputType="phone"
                        android:lines="1"
                        android:maxLength="10"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <AutoCompleteTextView
                        android:id="@+id/registration_edt_email"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:hint="Email"
                        android:inputType="textEmailAddress"
                        android:lines="1"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:orientation="horizontal"
                    android:weightSum="10">

                    <Spinner
                        android:id="@+id/registration_spnr_last_exam_passed"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="9.5"
                        android:background="@android:color/transparent"
                        android:entries="@array/last_exam_passed" />

                    <ImageView
                        android:id="@+id/registration_img_last_exam_passed"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight="0.5"
                        android:src="@drawable/ic_spinner_arrow" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:padding="5dp">

                    <TextView
                        android:id="@+id/registration_txt_date_of_birth"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="left"
                        android:lines="1"
                        android:padding="5dp"
                        android:text="Date of Birth"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="@color/registration_hint_color" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:padding="5dp">


                    <RadioGroup
                        android:id="@+id/radioGroup"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:paddingLeft="40dp"
                        android:paddingRight="40dp"
                        android:weightSum="1">

                        <RadioButton
                            android:id="@+id/radioButton"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="0.5"
                            android:buttonTint="@color/colorPrimary"
                            android:checked="false"
                            android:text="Male"
                            android:textColor="@color/registration_hint_color" />

                        <RadioButton
                            android:id="@+id/radioButton2"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="0.5"
                            android:buttonTint="@color/colorPrimary"
                            android:checked="false"
                            android:text="Female"
                            android:textColor="@color/registration_hint_color" />
                    </RadioGroup>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:orientation="horizontal"
                    android:weightSum="10">

                    <Spinner
                        android:id="@+id/registration_spnr_cast"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="9.5"
                        android:background="@android:color/transparent"
                        android:entries="@array/cast" />

                    <ImageView
                        android:id="@+id/registration_img_cast"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight="0.5"
                        android:src="@drawable/ic_spinner_arrow" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:orientation="horizontal"
                    android:weightSum="10">

                    <Spinner
                        android:id="@+id/registration_spnr_religion"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="9.5"
                        android:background="@android:color/transparent"
                        android:entries="@array/religion" />

                    <ImageView
                        android:id="@+id/registration_img_religion"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight="0.5"
                        android:src="@drawable/ic_spinner_arrow" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText

                        android:id="@+id/registration_edt_password"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:fontFamily="sans-serif"
                        android:hint="Password"
                        android:inputType="textPassword"
                        android:lines="1"
                        android:maxLength="18"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_confirm_password"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:fontFamily="sans-serif"
                        android:hint="Confirm Password"
                        android:inputType="textPassword"
                        android:lines="1"
                        android:maxLength="18"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background">

                    <EditText
                        android:id="@+id/registration_edt_parent_code"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"

                        android:hint="Parent Code (Optional)"
                        android:inputType="textCapWords"
                        android:lines="1"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:singleLine="true"
                        android:textColor="@color/registration_hint_color"
                        android:textColorHint="@color/registration_hint_color" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rounded_corder_background"
                    android:padding="5dp">

                    <CheckBox
                        android:id="@+id/registration_chk_agreement"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:buttonTint="@color/colorPrimary"
                        android:lines="1"
                        android:padding="10dp"
                        android:text="I Agree to the Terms And Conditions"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="@color/registration_hint_color" />

                </LinearLayout>

            </LinearLayout>
        </ScrollView>

        <LinearLayout
            android:id="@+id/buttonlinear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:orientation="vertical">

            <Button
                android:id="@+id/registration_btn_sign_up"
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:background="@color/colorPrimary"
                android:lines="1"
                android:singleLine="true"
                android:text="Submit"
                android:textColor="@color/white"
                android:textStyle="bold" />
        </LinearLayout>
    </RelativeLayout>


</LinearLayout>

添加


在scrollview上

找到解决方案了吗?@MortezaRastgoo:不幸的是,没有,这对片段很有效,但对活动不起作用
 android:focusable="true"
 android:descendantFocusability="beforeDescendants"