首页 > 解决方案 > 运行应用程序时出现键盘布局边缘?

问题描述

在此处输入图像描述

这是我使用dp尺寸创建的布局,使用键盘的相对布局,但是当我在手机上尝试使用键盘时,不知何故,我的键盘的右边缘被裁剪如下所示,这个问题的原因可能是什么?

在此处输入图像描述

这是我的xml代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_alignParentBottom="true"
    android:background="@color/colorPrimaryDark"
    android:id="@+id/Rel">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/texty"/>
    <TextView
        android:layout_width="60dp"
        android:layout_height="30dp"
        android:layout_marginLeft="70dp"
        android:id="@+id/xcor"/>
    <TextView
        android:layout_width="60dp"
        android:layout_height="30dp"
        android:layout_marginLeft="180dp"
        android:id="@+id/ycor"/>

    <Button
        android:layout_width="41dp"
        android:layout_height="@dimen/buttonh"
        android:layout_marginTop="@dimen/buttono1"
        android:background="@drawable/button"
        android:text="अ&quot;
        android:id="@+id/अ&quot;
        android:textSize="@dimen/text"/>
    <Button
        android:layout_width="41dp"
        android:layout_height="@dimen/buttonh"
        android:layout_marginTop="@dimen/buttono1"
        android:layout_marginLeft="41dp"
        android:background="@drawable/button"
        android:text="आ&quot;
        android:id="@+id/आ&quot;
        android:textSize="@dimen/text"/>
    ....

    Lots of Buttons


   .....
    <Button
        android:layout_width="41dp"
        android:layout_height="43dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="@dimen/buttono5"
        android:text="1"
        android:id="@+id/number"
        android:textSize="17dp"
        android:textColor="#FF494949"/>
    <Button
        android:layout_width="41dp"
        android:layout_height="43dp"
        android:layout_marginLeft="280dp"
        android:layout_marginTop="@dimen/buttono5"
        android:text="."
        android:id="@+id/dot"
        android:textSize="17dp"
        android:textColor="#FF494949"/>
    <ImageButton
        android:layout_width="60dp"
        android:layout_height="56dp"
        android:layout_marginLeft="330dp"
        android:layout_marginTop="192dp"
        android:src="@drawable/enterbutton"
        android:id="@+id/enter"
        android:textSize="17dp"/>




</RelativeLayout>

正如评论中所建议的那样。

我尝试将父母的宽度更改为某个恒定的 dp 而不是match_parent但结果是相同的。

编辑 我发现这个错误只发生在我的手机上,它是奥利奥,小米红米 Note 5。

标签: androidandroid-layoutandroid-serviceandroid-softkeyboardandroid-relativelayout

解决方案


你可以使用 layout_weight

   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal">

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>

它的响应式显示


推荐阅读