android - 运行应用程序时出现键盘布局边缘?
问题描述
这是我使用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但结果是相同的。
编辑 我发现这个错误只发生在我的手机上,它是奥利奥,小米红米 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>
它的响应式显示
推荐阅读
- python - 优化解决时返回函数调用和其他信息
- python - 如何在exec python中获取源代码
- amazon-web-services - Bitnami Ghost CMS aws 实例配置文件无效 JSON 问题
- leaflet - 有没有更聪明的方法来组合标记和多边形
- postgresql - postgres-rust 错误 42601(常见语法错误):正确发布变量表名?
- java - Spring:初始化应用程序后如何启动逻辑
- visual-studio - 通过 2019 构建工具安装时未检测到 MSVC2015
- csv - SQL Server 将 CSV 数据导入临时表无法查询导入的数据
- laravel - 将 MongoDB 与 Laravel 连接时出错
- git - Fork GitHub 存储库供个人使用和贡献