运行 应用程序出现键盘布局边缘?
Keyboard layout edge cropping up while running the app?
这是我使用 dp 尺寸创建的布局,使用键盘的相对布局,但是当我在 phone 上尝试键盘时,不知何故,右边缘我的键盘的一部分被裁剪了,如下所示,这个问题的原因可能是什么?
这是我的 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,但结果是一样的。
编辑
我发现这个错误只发生在我的 phone 上,它是奥利奥,小米红米 note 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>
其对显示的响应
这是我使用 dp 尺寸创建的布局,使用键盘的相对布局,但是当我在 phone 上尝试键盘时,不知何故,右边缘我的键盘的一部分被裁剪了,如下所示,这个问题的原因可能是什么?
这是我的 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,但结果是一样的。
编辑 我发现这个错误只发生在我的 phone 上,它是奥利奥,小米红米 note 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>
其对显示的响应