Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.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/Java:EditText焦点移动整个布局,并且只应移动ScrollView_Java_Android_Android Layout_Android Edittext_Focus - Fatal编程技术网

Android/Java:EditText焦点移动整个布局,并且只应移动ScrollView

Android/Java:EditText焦点移动整个布局,并且只应移动ScrollView,java,android,android-layout,android-edittext,focus,Java,Android,Android Layout,Android Edittext,Focus,此阶段应获取所有基本信息并添加所谓的“将军”,用户可以随意添加,但当我单击en“输入您的电话号码”编辑文本或将军的任何编辑文本,虚拟键盘出现时,整个布局被拉起,以便可以看到聚焦的编辑文本 问题是我需要在任何情况下都可以使用包含“确认”按钮的顶部功能区。我知道用户可以通过按下后退按钮来解决这个问题,但这是非常不现实的。我需要知道如何在所有其他内容都被提到的编辑文本拉起后,将缎带保持在那里 <?xml version="1.0" encoding="utf-8"?> <Linear

此阶段应获取所有基本信息并添加所谓的“将军”,用户可以随意添加,但当我单击en“输入您的电话号码”编辑文本或将军的任何编辑文本,虚拟键盘出现时,整个布局被拉起,以便可以看到聚焦的编辑文本

问题是我需要在任何情况下都可以使用包含“确认”按钮的顶部功能区。我知道用户可以通过按下后退按钮来解决这个问题,但这是非常不现实的。我需要知道如何在所有其他内容都被提到的编辑文本拉起后,将缎带保持在那里

<?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:orientation="vertical" >

    <LinearLayout
        android:id="@+id/topRibbonLL"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/firstDataTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical"
            android:layout_weight="1"
            android:text="Step 3: First data"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <Button
            android:id="@+id/confirmButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_weight="1"
            android:text="Confirm"
            android:onClick="newFileStep3ConfirmPressed" />

    </LinearLayout>

    <CheckBox
        android:id="@+id/shareableCheckBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Other people can share my file" />

    <TextView
        android:id="@+id/shareableDescription"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="16dp"
        android:text="Description of the shareableCheckBox effect."
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <ScrollView
        android:id="@+id/dataScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

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

            <EditText
                android:id="@+id/dataFileName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:focusable="true"
                android:focusableInTouchMode="true" >
            </EditText>

            <EditText
                android:id="@+id/dataFullName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="textPersonName"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <EditText
                android:id="@+id/dataAddress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="textPostalAddress"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <EditText
                android:id="@+id/dataPhoneNumber"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="phone"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Generals:"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <LinearLayout
                android:id="@+id/generalsContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <Button
                    android:id="@+id/newGeneralButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Add new general"
                    android:onClick="newGeneralButtonPressed" />

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

</LinearLayout>
点击所述编辑文本之前布局的屏幕截图:

点击所述编辑文本后布局的屏幕截图:

下面是布局的XML。“topRibbonLL”LinearLayout应始终保持其在顶部的位置,而其他所有内容都应通过点击提及的编辑文本来拉起

<?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:orientation="vertical" >

    <LinearLayout
        android:id="@+id/topRibbonLL"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/firstDataTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical"
            android:layout_weight="1"
            android:text="Step 3: First data"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <Button
            android:id="@+id/confirmButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_weight="1"
            android:text="Confirm"
            android:onClick="newFileStep3ConfirmPressed" />

    </LinearLayout>

    <CheckBox
        android:id="@+id/shareableCheckBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Other people can share my file" />

    <TextView
        android:id="@+id/shareableDescription"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="16dp"
        android:text="Description of the shareableCheckBox effect."
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <ScrollView
        android:id="@+id/dataScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

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

            <EditText
                android:id="@+id/dataFileName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:focusable="true"
                android:focusableInTouchMode="true" >
            </EditText>

            <EditText
                android:id="@+id/dataFullName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="textPersonName"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <EditText
                android:id="@+id/dataAddress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="textPostalAddress"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <EditText
                android:id="@+id/dataPhoneNumber"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="phone"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Generals:"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <LinearLayout
                android:id="@+id/generalsContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <Button
                    android:id="@+id/newGeneralButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Add new general"
                    android:onClick="newGeneralButtonPressed" />

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

</LinearLayout>

我解决了我的问题。我使用低优先级线程和while循环来重新定位功能区,只要它不在顶部且不可见。我还必须将根布局更改为RelativeLayout,以控制坐标