Android 当软键盘出现在屏幕上时,它会覆盖按钮和后面的文本

Android 当软键盘出现在屏幕上时,它会覆盖按钮和后面的文本,android,xml,android-layout,Android,Xml,Android Layout,我知道这个问题以前已经讨论过了,但我几乎尝试了所有可能的解决方案,但似乎都不起作用。 当软键盘出现时,我希望我的按钮和文本向上移动。现在软键盘隐藏了文本和按钮。 此外,我还添加了scrollview并更改了我的应用程序清单文件,但它不会向上移动按钮,也不会滚动 谢谢你的帮助 多谢各位 我的xml代码是 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schema

我知道这个问题以前已经讨论过了,但我几乎尝试了所有可能的解决方案,但似乎都不起作用。 当软键盘出现时,我希望我的按钮和文本向上移动。现在软键盘隐藏了文本和按钮。 此外,我还添加了scrollview并更改了我的应用程序清单文件,但它不会向上移动按钮,也不会滚动

谢谢你的帮助 多谢各位

我的xml代码是

<ScrollView 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:fillViewport="true"
android:orientation="vertical"
android:scrollbars="none"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CleaningBudgetAndMenPowerFeb13">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/Cleaning_Budget_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">


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

            <android.support.v7.widget.AppCompatImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:src="@drawable/attachpic" />
        </RelativeLayout>


    </android.support.v7.widget.Toolbar>

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/TotalBudgetSelection"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Cleaning_Budget_toolbar"
        android:layout_marginLeft="24dp"
        android:layout_marginStart="24dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/et_bg_services"
        android:backgroundTint="@color/colorPrimary"
        android:padding="4dp"
        android:text="Total"
        android:textAlignment="center"
        android:textColor="@color/white"
        android:textSize="20sp" />

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/hourlyRateSelection"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/TotalBudgetSelection"
        android:layout_marginEnd="24dp"
        android:layout_marginRight="24dp"
        android:background="@drawable/et_bg_services"
        android:backgroundTint="#cfcaca"
        android:padding="4dp"
        android:text="Hourly rate"
        android:textAlignment="center"
        android:textColor="@color/white"
        android:textSize="20sp" />


    <RelativeLayout
        android:id="@+id/RelativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/hourlyRateSelection"
        android:layout_marginTop="8dp"
        android:padding="5dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="24dp"
            android:layout_marginLeft="24dp"
            android:layout_marginRight="24dp"
            android:layout_marginStart="24dp"
            android:padding="10dp">


            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/whatIsYourBudget"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:text="What is your budget" />


            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/InputAmountForTotalLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/whatIsYourBudget"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="@drawable/et_bg_services"
                android:inputType="number"
                android:padding="10dp"
                android:text="د.ب" />


        </RelativeLayout>


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="24dp"
            android:layout_marginLeft="24dp"
            android:layout_marginRight="24dp"
            android:layout_marginStart="24dp"
            android:padding="5dp"
            android:visibility="gone"
     >


            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/HoursInHourlyRate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:text="Hours" />

            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/HoursinputInHourlyrateLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/HoursInHourlyRate"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="@drawable/et_bg_services"
                android:padding="10dp" />


            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/PayInHourlyRate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/HoursinputInHourlyrateLayout"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="16dp"
                android:text="Pay"
                android:textSize="16sp" />


            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/PayInHours"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/PayInHourlyRate"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="@drawable/et_bg_services"
                android:padding="10dp"
                android:text="د.ب" />


        </RelativeLayout>


    </RelativeLayout>

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/howManyPeoplDoYouNeed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="48dp"
        android:layout_below="@+id/RelativeLayout1"
        android:layout_marginStart="48dp"
        android:layout_marginTop="16dp"
        android:text="How many people do you need?" />



    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/increaseWorkerbutton"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_below="@id/howManyPeoplDoYouNeed"
        android:layout_marginTop="16dp"
        android:background="@drawable/budget_increase"
        android:text="+"
        android:textAlignment="center"
        android:textSize="20sp"
        android:layout_toRightOf="@+id/decreaseWorkerbutton"
        />
    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/decreaseWorkerbutton"
        android:layout_below="@id/howManyPeoplDoYouNeed"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="48dp"
        android:layout_marginTop="16dp"
        android:layout_marginStart="48dp"
        android:background="@drawable/budget_decrease"
        android:text="-"
        android:textAlignment="center"
        android:textSize="20sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/increaseWorkerbutton" />




    <android.support.v7.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="24dp"
        android:layout_below="@+id/howManyPeoplDoYouNeed"
        android:layout_toRightOf="@id/increaseWorkerbutton"
        android:layout_marginTop="16dp"
        android:layout_marginStart="24dp"
        android:text="2"
        android:textSize="20sp"
        android:textStyle="bold" />



    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_marginTop="8dp"
        android:layout_below="@+id/decreaseWorkerbutton"
        >

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/budgettext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAlignment="center"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginLeft="8dp"
            android:layout_alignParentRight="true"
            android:layout_alignParentLeft="true"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:text="@string/Budget_resource"
            android:textColor="#6dbe3a"
            android:textSize="20sp"
            />

        <LinearLayout
            android:id="@+id/linearlayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/budgettext"
            android:gravity="center"
            android:orientation="horizontal">


            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/TotalAmountToPayperPerson"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2.000 BD"
                android:padding="5dp"
                android:textAlignment="center"
                android:textSize="16sp" />


            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/PerPersonAmount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:padding="5dp"
                android:text="Per Person"
                android:textSize="16sp" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearlayout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearlayout1"
            android:gravity="center"
            android:orientation="horizontal">


            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/TotalAmountIfHourlyRate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:padding="5dp"
                android:text="Total :"
                android:textAlignment="center"
                android:textSize="16sp" />



            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/TotalAmountInEnd"
                android:layout_width="wrap_content"
                android:padding="5dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                android:text="16.000 BD"
              />

        </LinearLayout>


        <android.support.v7.widget.AppCompatButton
            android:id="@+id/ContinueToImages"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_below="@+id/linearlayout2"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="8dp"
            android:layout_alignParentRight="true"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:background="@drawable/btn_bg_services"
            android:paddingLeft="24dp"
            android:paddingRight="24dp"
            android:text="Continue"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />


    </RelativeLayout>





</RelativeLayout>


</ScrollView>

以下是有关预期活动的应用程序清单

    <activity android:name=".CleaningBudgetAndMenPowerFeb13"
        android:windowSoftInputMode="adjustPan"
        />

Style.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlNormal">@color/white</item>

</style>

<style name="Dialog" parent="Theme.AppCompat.Dialog">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowIsFloating">true</item>
</style>

<style name="FilterDialogTheme" parent="@android:style/Theme.Holo.Light.Dialog">
    <item name="android:windowNoTitle">false</item>
</style>

错误的
符合事实的
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
@颜色/白色
错误的
符合事实的
错误的

将以下属性添加到清单内的活动标记中

android:windowSoftInputMode="adjustPan"
adjustPan向上滑动整个屏幕,以使其保持在视野内。如果希望调整屏幕大小以获得可用空间,也可以使用adjustResize


注意*如果您在没有工具栏的情况下使用全屏活动,则adjustResize属性无法正常工作。

共享活动的屏幕截图和清单声明。此外,如果您的活动通过应用程序或自己的标签附加了主题,如AppTheme,请共享主题,以便我可以检查这些主题,也值得注意,只是一个友好的评论,这里没有冒犯的意思。但是您的UI可视化树太深,嵌套布局太多,包装布局,包装布局。你应该专注于使它更浅,清理它,使用适当的布局父母来处理你的需要。您可以用更少的xml元素完成相同的布局,这将清理UI处理的疑难解答,并加快加载速度。我在这里计算了一个屏幕使用的8个父布局。Relative和Lineari已在上述问题中添加了应用程序清单文件。我将尝试减少xml标记并使其更合适。感谢suggestionOk,因此它继承了AppTheme。你能从styles.xmlHi提供AppTheme吗?它是按照你最初显示的方式开始工作的,但我删除了getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT\u INPUT\u ADJUST\u PAN);从那时起,是谁制造了麻烦