SoftKeyboard覆盖按钮和后面的文字,同时出现在屏幕上



我知道这个问题以前已经讨论过,但是我几乎尝试了所有可能的解决方案,但似乎没有任何作用。我希望当出现软键时我的按钮和文本会向上移动。现在,软键隐藏其后面的文本和按钮。另外,我添加了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"

调节锅在整个屏幕上滑动以保持其视图。如果您希望它只是为可用空间调整屏幕大小,也可以使用Adjustresize。

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

最新更新