Android:键盘与 EditText 重叠(带有打印屏幕)

2023-12-20

我有一个 EditText (用户可以输入numbers在), 因此,当用户单击 EditText 文本框时,将打开带有数字的键盘。

正如您所看到的,键盘隐藏了文本框的一小部分。

But when I press a key, for example, 0, it looks ok. This is how it looks after after clicking 0

我能做些什么(除了将 EditText 放在更高的位置之外),使它看起来像第二张图片中的那样吗?

Edit:.xml 代码:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:weightSum="1">
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content">
    <LinearLayout android:layout_width="wrap_content" android:orientation="vertical" android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_alignParentRight="true">
        <android.widget.CheckedTextView android:id="@+id/checkedTextView1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:textSize="17sp" android:text="@string/toString"></android.widget.CheckedTextView>
        <AutoCompleteTextView android:layout_height="wrap_content" android:id="@+id/autoCompleteTextView1" android:layout_width="fill_parent" android:text="@string/emptyString" android:textSize="17sp" android:gravity="top|left" android:minHeight="62dp">
            <requestFocus></requestFocus>
        </AutoCompleteTextView>
        <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout2">
            <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="0.33333333333" android:text="@string/contactsString" android:textSize="17sp" android:id="@+id/contactsButton"></Button>
            <Button android:layout_weight="0.33333333333" android:layout_height="wrap_content" android:text="@string/groupsString" android:layout_width="fill_parent" android:id="@+id/groupsButton" android:textSize="17sp"></Button>
            <Button android:layout_weight="0.33333333333" android:layout_height="wrap_content" android:text="@string/favouritesString" android:layout_width="fill_parent" android:id="@+id/button3" android:textSize="17sp"></Button>
        </LinearLayout>
        <TextView android:id="@+id/textView1" android:text="@string/messageString" android:layout_height="wrap_content" android:textSize="17sp" android:layout_width="fill_parent"></TextView>
        <EditText android:layout_height="wrap_content" android:id="@+id/editText1" android:layout_width="fill_parent" android:gravity="top|left" android:minHeight="105dp"></EditText>
        <TextView android:id="@+id/textView2" android:text="@string/repetition" android:layout_height="wrap_content" android:layout_width="fill_parent" android:textSize="17sp"></TextView>
        <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/spinner"></Spinner>
        <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout3" android:layout_width="fill_parent">
            <ImageView android:src="@drawable/button_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_weight="0.1"></ImageView>
            <EditText android:layout_height="wrap_content" android:id="@+id/timeET" android:inputType="number" android:layout_width="wrap_content" android:layout_weight="0.4"></EditText>
            <ImageView android:src="@drawable/button_date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView2" android:layout_weight="0.1"></ImageView>
            <EditText android:layout_height="wrap_content" android:id="@+id/dateET" android:inputType="number" android:layout_width="wrap_content" android:layout_weight="0.4" android:layout_marginRight="3dp"></EditText>
        </LinearLayout>
        <RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="fill_parent" android:layout_height="fill_parent">
            <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_alignParentLeft="true">
                <Button android:layout_weight="0.5" android:layout_height="wrap_content" android:text="@string/button_ok" android:layout_width="fill_parent" android:id="@+id/button4" android:textSize="17sp"></Button>
                <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/button5" android:layout_weight="0.5" android:text="@string/button_cancel" android:textSize="17sp"></Button>
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</RelativeLayout>

</LinearLayout>

我已经尝试过你的 XML,是的,你是对的,问题发生了。

为了解决这个问题,我在 MainActivity.java 中编写了这一行,希望对您有所帮助,并将布局 XML 放入 ScrollView 中。

Activity

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.temp);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

        final EditText time = (EditText)findViewById(R.id.timeET);
        time.setOnTouchListener(new OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                time.requestLayout();
                MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

                return false;
            }
        });
        final EditText date = (EditText)findViewById(R.id.dateET);
        date.setOnTouchListener(new OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                time.requestLayout();
                MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

                return false;
            }
        });
         }

And The XML就好像,

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" > 

        <ScrollView android:id="@+id/scrollView1"
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent" 
        android:weightSum="1">
---
---
---
        </ScrollView> 
</LinearLayout> 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android:键盘与 EditText 重叠(带有打印屏幕) 的相关文章

  • 如何获取每个StorageVolume的可用大小和总大小?

    背景 谷歌 悲伤 计划破坏存储权限 https www xda developers com android q storage access framework scoped storage 这样应用程序将无法使用标准文件 API 和文件
  • Android短音的正确播放方法?

    我正在创建一个应用程序 屏幕上将有多个图像 这些图像将是按钮 点击时会播放短促的声音 我对此进行了研究 只能找到我当前用来播放声音的方法 这似乎根本没有响应 我希望声音能够快速播放并且能够响应多次快速点击 我不确定这在 Android 中是
  • Cheesesquare:enterAlways 会产生错误的布局

    Adding enterAlways到 Cheesesquare 演示的滚动标志
  • Android Studio:XML 布局中的“包装在容器中”

    编辑 XML 布局文件时 Eclipse 有一项称为 包裹在容器中 的功能 重新格式化 gt Android gt 可让您选择一个或多个视图并在其周围包裹您选择的布局 Android Studio中有类似的东西吗 目前正在实施中 问题 69
  • 如何在android中显示保存在sdcard文件夹中的图像[关闭]

    这个问题不太可能对任何未来的访客有帮助 它只与一个较小的地理区域 一个特定的时间点或一个非常狭窄的情况相关 通常不适用于全世界的互联网受众 为了帮助使这个问题更广泛地适用 访问帮助中心 help reopen questions 当我正在显
  • 在 Cordova 应用程序中获取额外功能

    我们有两个 Android 应用程序 一个使用本机 Java 实现 另一个使用 Ionic 编写 Ionic 应用程序启动我的应用程序 这是使用灯插件 https github com lampaa com lampa startapp 我
  • java.lang.IllegalStateException:应用程序 PagerAdapter 更改了适配器的内容,而没有调用 PagerAdapter#notifyDataSetChanged android

    我正在尝试使用静态类将值传递给视图 而不是使用意图 因为我必须传递大量数据 有时我会收到此错误 但无法找出主要原因是什么 Error java lang IllegalStateException The application s Pag
  • Android 深度链接至 Instagram 应用

    Instagram 已经发布了 iOS 深层链接的 url 方案 但尚未为 Android 创建文档 有没有办法深入链接到 Android 上的 Instagram 应用程序 以转到 Instagram 应用程序中的特定位置 例如 Inst
  • Android Eclipse 上的 Web 服务

    我是 android eclipse java 的新手 事实上这个论坛也是如此 有人遇到过这种情况吗 从用户那里获取输入并通过使用 android eclipse 中的 Web 服务来显示适当的结果 有可用的示例吗 非常感谢 我正在发布教程
  • Android 手机作为 GSM 调制解调器在 PC 上发送/接收短信?

    是否可以将 Android 移动设备用作 PC 上的 GSM 调制解调器 我正在 net下开发应用程序来发送 接收短信等 现在我想通过 USB 将我的 Android 设备连接到我的 PC 并将其用作 GSM 调制解调器来与其通信 这里是参
  • 当 OnFocusChangeListener 应用于包装的 EditText 时,TextInputLayout 没有动画

    不能比标题说得更清楚了 我有一个由文本输入布局包裹的 EditText 我试图在 EditText 失去焦点时触发一个事件 但是 一旦应用了事件侦听器 TextInputLayout 就不再对文本进行动画处理 它只是位于 editText
  • 使用片段时应用程序崩溃

    我正在处理碎片和 我的代码中有一个我找不到的问题 logcat 指向我的一个片段中的这段代码 Override public View onCreateView LayoutInflater inflater ViewGroup conta
  • logcat 中 mSecurityInputMethodService 为 null

    我写了一点android应显示智能手机当前位置 最后已知位置 的应用程序 尽管我复制了示例代码 并尝试了其他几种解决方案 但似乎每次都有相同的错误 我的应用程序由一个按钮组成 按下按钮应该log经度和纬度 但仅对数 mSecurityInp
  • Mipmap 与可绘制文件夹[重复]

    这个问题在这里已经有答案了 我正在使用 Android Studio 1 1 Preview 1 我注意到 当我创建一个新项目时 我得到以下层次结构 不同 DPI 的 Mipmap 文件夹 不再有不同 DPI 的可绘制文件夹 我应该将所有资
  • 使用 AsyncTask 传递值

    我一直在努力解决这个问题 但我已经到了不知道该怎么办的地步 我想做的是使用一个类下载文件并将其解析为字符串 然后将该字符串发送到另一个类来解析 JSON 内容 所有部件都可以单独工作 并且我已经单独测试了所有部件 我只是不知道如何将值发送到
  • Dagger 2 没有生成我的组件类

    我正在使用 Dagger 2 创建我的依赖注入 几个小时前它还在工作 但现在不再生成组件 这是我创建组件的地方 public class App extends Application CacheComponent mCacheCompon
  • 上网本上可以进行Android开发吗? [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我想使用我的上网本进行 Android 开发 但是当我尝试使用 Eclipse 运行 SDK 时 没有加载任何内容 上网本对于 Android 开发来
  • 找不到符号 NOTIFICATION_SERVICE?

    package com test app import android app Notification import android app NotificationManager import android app PendingIn
  • 没有支持 FEATURE_CAMERA_EXTERNAL 的 Android 设备

    根据this doc https source android com devices camera external usb cameras一些 Android 设备允许使用 Camera2 API 访问外部 USB 摄像头 我检查了大约
  • 如何使用 AccessibilityService 在 Android 中模拟按键

    我正在编写一个辅助服务 我一直在尝试在应用程序上进行一些自动搜索 我使用accessibilityservice action paste来填充EditText 然后我需要模拟软键盘上的按键 但我不知道如何做 你们能帮我一下吗 你可以尝试A

随机推荐

  • C# 执行外部程序并捕获(流式传输)输出

    我正在编写一个程序来处理一些视频文件 我正在使用 ffmpeg 可执行文件将多个文件合并到一个文件中 该命令需要几分钟才能完成 因此 我需要一种方法来 监视 输出 并在 GUI 上显示进度条 查看以下 stackoverflow 主题 如何
  • 使用动态规划对列表进行分区

    我在这里发布了一些与我一直在尝试从事的项目相关的内容 但我不断遇到设计问题并且必须从头开始设计 所以我想知道我是否可以发布我正在尝试做的事情 并且有人可以帮助我了解如何获得我想要的结果 背景 我是编程新手 正在努力学习 因此 我开展了一个我
  • Binutils LD 创建巨大文件

    我正在尝试创建尽可能小的 ELF 我创建了一个像这样的测试文件 NASM 语法 SECTION text dd 0xdeadbeef 使用此链接描述文件 SECTIONS text text 然后我检查了平面二进制文件的大小 并通过两种方式
  • 将 UDF 应用于 Spark Dataframe 中的多个列

    我有一个如下所示的数据框 id age rbc bgr dm cad appet pe ane classification 3 48 0 normal 117 0 no no poor yes yes ckd 我写了一个 UDF 来转换分
  • 终止或停止 HtmlUnit

    我使用 htmlunit 测试一些网站 我注意到 Htmlunit 卡在一些网页上 这个问题导致调用 htmlunit 的线程不会终止 请您知道有什么方法可以停止 Htmlunit 就像在真正的网络浏览器中一样 您只需单击浏览器停止按钮即可
  • 考虑到每个静态库定义导出的功能(vc++ 2008),如何将多个静态链接库合并到一个 dll 中?

    鉴于每个静态库都定义导出功能 vc 2008 如何将多个静态链接库合并到单个 dll 中 在存在单个 dll 项目和静态链接的多个子项目 在 dll 项目中 的多项目布局中 尽管被标记为 declspec export 子项目 lib 中的
  • python Tkinter 中的简单加载屏幕

    我是一个Python初学者 尤其是tkinter 我想制作一个简单的 python 脚本的 加载屏幕 并在脚本结束后关闭 但制作窗户需要mainloop函数 这意味着它将无限循环或等待用户交互 或者我认为如此 并且它将消除 加载 屏幕的想法
  • Python 将 k-means 集群与实例关联

    我已阅读文档here http scikit learn org stable modules generated sklearn cluster KMeans html以及看着this http fromdatawithlove theg
  • 在 MongoDB 中搜索多个集合

    我知道 MongoDB 的理论以及不支持联接的事实 并且我应该尽可能使用嵌入文档或非规范化 但这里是 我有多个文档 例如 用户 嵌入了 Suburbs 但也有 名字 姓氏 郊区 其中嵌入州 嵌入 School 的 Child 属于 User
  • 在maven中查找定义属性的地方

    我目前正在各种项目和 git repo 中重构大量 pom xml 有时 项目 A 中的 pom 需要项目 B 中定义的工件 其版本由属性定义
  • 如何构建自动更新的拖放层次树

    我目前正在 R 工作 需要一种可视化分层树的方法 我希望能够最初定义一棵树 其中每个节点都有一个父节点 每个父节点可以有多个子节点 我希望能够将节点拖放到不同父级下并执行一些计算 在 R 中 然后在可视化上进行更新 例如假设每个节点都有一个
  • 正则表达式“包含”另一个正则表达式

    有没有办法测试一个正则表达式是否 包含 另一个正则表达式 例如 RegEX1 a b RegEx2 a1 b RegEX1 包含 RegEX2 据我所知 这是不可能的 我错了吗 OK joel neely has shown that it
  • C++ Boost.ASIO async_read_until 慢

    我遇到了一个不寻常的问题 我有一个 C Boost ASIO Web 服务器 为了处理传入请求 我使用以下代码 boost asio async read until socket response r n r n boost bind c
  • 如何使用seaborn制作气泡图

    import matplotlib pyplot as plt import numpy as np data x IEEE Elsevier Others y 7 6 2 import seaborn as sns plt legend
  • Modelica - Dymola Python 界面:将输出格式设置为文本

    我通过 Dymola Python 界面使用 Dymola 运行 Modelica 模拟 我的目标是将结果文件写入文本输出 即写入 txt文件 即使我的模型包含注释 Dymola experimentSetupOutput textual
  • C/C++ 中的单引号、双引号和 sizeof('a')

    我正在看问题C 或 C 中的单引号与双引号 https stackoverflow com questions 3683602 single quotes vs double quotes in c 我无法完全理解给出的解释 所以我写了一个
  • 位运算符优先级

    我在类 C 语言中遇到过几次的问题是 original included excluded BAD 由于优先级 它解析为 original included excluded excluded has no effect 有谁知道三个独立优
  • Git 预提交挂钩在 GitHub for mac 中失败(在命令行上运行)

    我创建了一个非常简单的预提交脚本 usr bin env sh Run tests npm test if ne 0 then echo Tests failed Aborting exit 1 fi exit 0 当我跑步时git com
  • MyBatis - 找不到构造函数

    我在 MyBatis 映射方面遇到问题 我有一个像这样的域类 public class MyClass private Long id private Date create private String content MyClass L
  • Android:键盘与 EditText 重叠(带有打印屏幕)

    我有一个 EditText 用户可以输入numbers在 因此 当用户单击 EditText 文本框时 将打开带有数字的键盘 正如您所看到的 键盘隐藏了文本框的一小部分 But when I press a key for example