首页 > 解决方案 > 显示软键盘时如何仅调整布局的一部分(android)?

问题描述

你好?我是一个新手 android 开发人员。

我只想让键盘上的按钮向上而不触碰其他任何东西。但是,即使我尝试了各种方法(线性布局、滚动视图、编程、修改 Manifest.xml 文件:adjustResize、adjustPan ... 等),它也会不断改变不需要的布局。

在这种状态下,我只想在键盘上放一个按钮。

像这样,不需要的布局总是会改变。

我该怎么做?

这是我的 AndroidManifest.xml 代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ulimbridge.serendipity"
android:versionCode="3919"
android:versionName="0.0.3919"
tools:ignore="GoogleAppIndexingWarning">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="com.android.vending.BILLING" />

<application
    android:name=".kakao.GlobalApplication"
    android:allowBackup="true"
    android:icon="@drawable/favicon"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">

    <!--        This Activity!!-->
    <activity android:name=".views.LoginActivityAuthentication"
              android:windowSoftInputMode="adjustResize"></activity>


         ......


    </application>

</manifest>

这是 activity_login_authentification.xml 代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
tools:context=".views.LoginActivityAuthentication"
android:id="@+id/authen">


<android.support.v4.widget.NestedScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:fitsSystemWindows="true">


    <!--content-->
    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.constraint.Guideline
            android:id="@+id/leftmargin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.0666" />

        <android.support.constraint.Guideline
            android:id="@+id/rightmargin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.9333" />

        <!--    타이틀 바-->
        <View
            android:id="@+id/auth_title"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHeight_percent="0.0875"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"

            />

        <TextView
            android:id="@+id/auth_text"
            style="@style/Kor16DarkMediumCenter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/nanum_square_b"
            android:text="@string/register_title"
            android:textStyle="bold"
            app:layout_constraintBottom_toBottomOf="@+id/auth_title"
            app:layout_constraintEnd_toEndOf="@id/auth_title"
            app:layout_constraintStart_toStartOf="@id/auth_title"
            app:layout_constraintTop_toTopOf="@id/auth_title" />

        <com.ulimbridge.serendipity.utils.AlphaImageView
            android:id="@+id/auth_back"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:src="@drawable/ico_back_d"
            app:layout_constraintBottom_toBottomOf="@+id/auth_title"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0444"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/auth_title"
            app:layout_constraintWidth_percent="0.0666" />

        <!--            내용-->
        <TextView
            android:id="@+id/auth_guide"
            style="@style/Kor24DarkLightLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/auth_guide"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="@id/leftmargin"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.12329" />

        <com.ulimbridge.serendipity.utils.CustomEditText
            android:id="@+id/auth_et_email"
            style="@style/Kor16DarkRegularLeft"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@drawable/custom_edit_text"
            android:ems="10"
            android:hint="@string/register_et_email"
            android:inputType="textEmailAddress"
            android:textColorHint="@color/colorSilver"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="@id/rightmargin"
            app:layout_constraintHeight_percent="0.0875"
            app:layout_constraintStart_toStartOf="@id/leftmargin"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.22857" />

        <com.ulimbridge.serendipity.utils.CustomEditText
            android:id="@+id/auth_et_pw"
            style="@style/Kor16DarkRegularLeft"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginTop="8dp"
            android:background="@drawable/custom_edit_text"
            android:ems="10"
            android:hint="@string/auth_et_pw"
            android:inputType="textPassword"
            android:textColorHint="@color/colorSilver"
            app:layout_constraintEnd_toEndOf="@id/rightmargin"
            app:layout_constraintHeight_percent="0.0875"
            app:layout_constraintStart_toStartOf="@id/leftmargin"
            app:layout_constraintTop_toBottomOf="@+id/auth_et_email" />

        <TextView
            android:id="@+id/auth_findid"
            style="@style/Kor12BodyRegularLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="아이디를 잊으셨나요?"
            app:layout_constraintStart_toStartOf="@id/leftmargin"
            app:layout_constraintTop_toBottomOf="@id/auth_et_pw" />

        <TextView
            android:id="@+id/auth_findpw"
            style="@style/Kor12BodyRegularRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="비밀번호를 잊으셨나요?"
            app:layout_constraintEnd_toEndOf="@id/rightmargin"
            app:layout_constraintTop_toBottomOf="@id/auth_et_pw" />
    </android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
    <!--The button I want to put on the keyboard-->
    <Button
    android:id="@+id/auth_ok"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="@drawable/custom_ok_button"
    android:text="@string/register_ok"
    android:textColor="#FFFFFF"
    android:layout_alignParentBottom="true"

    android:enabled="false"
    />
</RelativeLayout>

PS。对不起我的英语不好。

标签: javaandroid

解决方案


推荐阅读