简体   繁体   English

Android中出现键盘时按钮的问题

[英]Problems with buttons when keyboard comes out in Android

I've read a lot of community responses in order to solve the keyboard problem in android but I'm just not able to solve it. 为了解决android中的键盘问题,我已经阅读了很多社区反馈,但我只是无法解决。

I would appreciate if someone would to help me. 如果有人愿意帮助我,我将不胜感激。 My problem is that everytime the keyboard comes out, all the lower screen buttons merge with the upper ones. 我的问题是,每次键盘出来时,所有下部屏幕按钮都会与上部屏幕按钮合并。

Here is my XML. 这是我的XML。

<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:id="@+id/pantallaPrincipalGenerarBackgroundView">

<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView"
    android:fillViewport="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentTop="true">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Seleccione dificultad"
            android:id="@+id/textView"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:gravity="center_horizontal" />

        <RadioGroup

            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView"
            android:gravity="top|center"
            android:id="@+id/linearLayout">

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Facil"
                android:id="@+id/FacilButton"

                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="20dp" />

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Medio"
                android:id="@+id/MedioButton2"
                android:layout_marginRight="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="20dp" />

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Difícil"
                android:id="@+id/DifícilButton"

                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="20dp" />


        </RadioGroup>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearLayout"
            android:id="@+id/linearLayout2"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp">

            <EditText
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:inputType="number"
                android:id="@+id/longitudText"
                android:hint="Introduce longitud"
                android:singleLine="true" />

            <Button
                android:layout_marginTop="10dp"
                android:layout_width="115dp"
                android:layout_height="wrap_content"
                android:text="Generar"
                android:id="@+id/Generarbutton"
                android:layout_gravity="right"
                android:layout_marginLeft="20dp" />
        </LinearLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Pass"
            android:id="@+id/passwordText"
            android:layout_below="@+id/linearLayout2"
            android:layout_centerHorizontal="true"
            android:layout_margin="5dp"
            android:textColor="#ff1024ff"
            android:textSize="15dp"
            android:singleLine="true"
            android:shadowColor="#ff69ff00" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Usuario"
            android:id="@+id/textView2"
            android:layout_below="@+id/passwordText"
            android:layout_centerHorizontal="true" />

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/newUserText"
            android:layout_below="@+id/textView2"
            android:layout_centerHorizontal="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:hint="Introduzca usuario"
            android:layout_margin="7dp"
            android:singleLine="true" />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/linearLayout4">

        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/newUserText"
            android:layout_centerHorizontal="true">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Seleccione el servicio"
                android:id="@+id/textView3"
                android:layout_below="@+id/newUserText"
                android:layout_centerHorizontal="true" />
        </LinearLayout>

        <Button
            android:layout_width="200dp"
            android:layout_height="100dp"
            android:text="Guardar"
            android:id="@+id/guardarButton"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Servicios"
            android:drawableLeft="@drawable/flechaizquierda"
            android:id="@+id/abrirListaServiciosButton"
            android:layout_above="@+id/guardarButton"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toEndOf="@+id/abrirListaServiciosButton"
            android:gravity="center"
            android:weightSum="1"
            android:layout_alignTop="@+id/abrirListaServiciosButton"
            android:layout_toRightOf="@+id/abrirListaServiciosButton"
            android:layout_marginTop="23dp"
            android:layout_alignRight="@+id/newUserText"
            android:layout_alignEnd="@+id/newUserText">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="SERVICIO"
                android:id="@+id/textoMostrarServicioSeleccionado"
                android:textColor="#ff000000" />

            <ImageView
                android:layout_width="80dp"
                android:layout_height="match_parent"
                android:id="@+id/imageMostrarServicioSeleccionado" />
        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toEndOf="@+id/guardarButton"
            android:id="@+id/linearLayout5"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true">

            <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:text="Salir"
                android:id="@+id/salirycerrarPantallaGenerarButton"
                android:layout_alignBottom="@+id/guardarButton"
                android:layout_alignLeft="@+id/goToSegundabutton"
                android:layout_alignStart="@+id/goToSegundabutton"
                android:layout_margin="1dp" />

            <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:text="Cancelar"
                android:id="@+id/goToSegundabutton"
                android:layout_alignTop="@+id/guardarButton"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="0dp" />
        </LinearLayout>

    </RelativeLayout>
</ScrollView>

Thank you for your help :) 谢谢您的帮助 :)

您可以通过将其添加到清单文件中的“活动”标签中来防止调整活动大小:

android:windowSoftInputMode="adjustPan"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM