【问题标题】:how to hide the footer fragment when keyboard appear键盘出现时如何隐藏页脚片段
【发布时间】:2017-04-06 19:38:54
【问题描述】:

我的活动中有页脚栏。我使用片段作为页脚栏。这是屏幕截图。 。当我将文本添加到EditText 时,键盘显示如下。 。我想在键盘出现时隐藏页脚。我在活动中使用了android:windowSoftInputMode="adjustPan"。我想知道任何建议。

谢谢。

【问题讨论】:

  • onTouchListener 添加到EditText 中,并在触摸时以编程方式隐藏页脚 (setVisibility = "GONE")。如果您无法做到,请告诉我并粘贴此布局的 XML。
  • 是的。可以使用onTouchListener。但是当键盘隐藏时,页脚应该再次显示。
  • 键盘隐藏在哪个事件上?我猜当按下 Enter 键时 - 向右(或向下箭头)?您可以轻松检测到这些事件,在 google 中尝试一下,我立即发现了大量用于检测这些事件的示例。
  • 你能给我举个例子吗?我找到了这个stackoverflow.com/q/16159802/1156041 问题,但没有合适的答案。
  • 好的,我没有找到任何关于这个按钮的特别信息,但你可以这样做:public boolean onKey(View v, int keyCode, KeyEvent event) { //Log the keyCode and the KeyEvent here, return with the results return true; } 完成日志后,请返回结果并发布完整的回答。

标签: android android-fragments


【解决方案1】:

我遇到了同样的情况,但没有找到任何解决方案,所以刚刚开始了另一个关于 textview 的活动。在此活动中再次完成活动时,从下一个活动的文本视图中获取结果并将文本放置在当前活动的文本视图中。它有效

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,我刚刚从清单文件中删除了 android:windowSoftInputMode="adjustPan" 并且得到了所需的输出

    【讨论】:

      【解决方案3】:
      var originalHeight = document.documentElement.clientHeight;
      var originalWidth = document.documentElement.clientWidth;
      $(window).resize(function() {
          // Control landscape/portrait mode switch
          if (document.documentElement.clientHeight == originalWidth &&
               document.documentElement.clientWidth == originalHeight) {
              originalHeight = document.documentElement.clientHeight;
              originalWidth = document.documentElement.clientWidth;
          }`enter code here`
          // Check if the available height is smaller (keyboard is shown) so we hide the footer.
         if (document.documentElement.clientHeight < originalHeight) {
             $('.footer').hide();
         } else {
             $('.footer').show();
         }
      });
      
      try this it will work and  give  class="footer"
      

      【讨论】:

      • 是安卓,不是javascript
      • @Frank 我为 Cordova / PhoneGap 提供了解决方案,感谢您的信息。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 2019-12-20
      • 2015-02-22
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      • 1970-01-01
      相关资源
      最近更新 更多