一个接一个挤压空间

时间:2018-03-23 07:59:33

标签: android xml

我不确定我应该在这里添加什么标题,但这是问题。

我想在键盘输出时将我的字段附加到屏幕底部。 当没有键盘时,我希望我的字段位于屏幕的中心。

基本上1和2是空格,我希望Space I成为键盘输出时挤压的第一个候选者。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <android.support.v4.widget.Space
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/walletPasswordEditLayout"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginStart="16dp">

            <android.support.design.widget.TextInputEditText
                style="@style/AppEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"/>

        </android.support.design.widget.TextInputLayout>

        <Button
            style="@style/AppButton.Black"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginStart="16dp"
            android:text="@string/unlock_button"/>

        <android.support.v4.widget.Space
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>

    </LinearLayout>

</FrameLayout>

enter image description here

2 个答案:

答案 0 :(得分:0)

在您的活动中添加此内容

$

答案 1 :(得分:0)

请检查此Link

您可以在您的宣言中添加您想要阻止此类问题的活动。还要确保如果您有更多内容,请使用scrollView作为父级。而软输入模式为“adjustResize”

android:windowSoftInputMode="adjustResize" 

android:windowSoftInputMode="adjustPan"