这是我使用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="अ"
android:id="@+id/अ"
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="आ"
android:id="@+id/आ"
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,但结果是相同的。
编辑我发现此错误仅发生在我的手机上,这是Oreo小米Redmi注意事项5。
您可以使用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>
通过显示进行响应