This question already has answers here:
EditText, adjustPan, ScrollView issue in android

(4个答案)


5年前关闭。




我在所有布局上都设置AdjustPan为:

<style name="AppTheme" parent="AppBaseTheme">


    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowSoftInputMode">adjustPan</item>
</style>


但是有一种布局包含几个静态片段,如果我单击片段内的文本框,则背景图像会调整大小,并且与父级底部对齐的视图会上升。

我试图将清单设置为:

<activity
        android:name=".CaptureVisitActivity"
        android:label="@string/title_activity_capture_visit"
        android:windowSoftInputMode="adjustPan" >


但是,再次调整窗口大小。

这是布局:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_landscape"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".CaptureVisitActivity" >

    <TextView
        android:id="@+id/tv_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="@string/title_activity_capture_visit"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/tv_title"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="90dp"
        android:baselineAligned="false" >

        <ScrollView
            android:id="@+id/sv1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.3" >

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

                <fragment
                    android:id="@+id/frag_summary"
                    android:name="com.vancert.activities.CaptureVisitActivity$JobSummaryFragment"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:layout="@layout/fragment_job_summary" />

                <fragment
                    android:id="@+id/frag_further_work"
                    android:name="com.vancert.activities.CaptureVisitActivity$JobFurtherWorkFragment"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:layout="@layout/fragment_further_work" />
            </LinearLayout>
        </ScrollView>

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

            <fragment
                android:id="@+id/fragment1"
                android:name="com.vancert.activities.CaptureVisitActivity$JobReportsFragment"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                tools:layout="@layout/fragment_job_reports" />
        </LinearLayout>

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

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

    <include
        android:layout_width="match_parent"
        android:layout_height="90dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        layout="@layout/layout_footer" />

</RelativeLayout>


而fragment_job_summary是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin" >

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

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/summary"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv_summary"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginStart="@dimen/activity_horizontal_margin" />
    </LinearLayout>

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

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

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/engineer_notes_label" />

            <Button
                android:id="@+id/btn_fast_text"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:background="@drawable/background_button4"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:text="@string/fasttext" />
        </LinearLayout>

        <EditText
            android:id="@+id/et_eng_notes"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textMultiLine"
            android:maxLines="3" >
        </EditText>
    </LinearLayout>

</LinearLayout>


有什么建议么?

最佳答案

我非常抱歉。我只是谷歌不够。

请参阅:EditText, adjustPan, ScrollView issue in android

它可以解决这个问题。

09-26 02:54