android:windowSoftInputMode=“adjustPan"不管用

android:windowSoftInputMode=quot;adjustPanquot; is not working(android:windowSoftInputMode=“adjustPan不管用)
本文介绍了android:windowSoftInputMode=“adjustPan"不管用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个愚蠢的问题,请按照下面的图片进行操作

I have silly problem please follow the below pics

当我点击输入电子邮件时,它看到如下图,

And when i clicked on Enter Email it saw like below pic,

尽管使用 android:windowSoftInputMode="adjustPan" android Lollipop 主题和工具栏,问题还是出现了,

Now the problems are coming inspite of using android:windowSoftInputMode="adjustPan" android Lollipop theme and toolbar,

  1. 图片变小了.
  2. 电子邮件编辑文本应该显示在键盘上方,但它没有.

提出一些解决方案.

推荐答案

首先确保您在 xml 布局中提供了 ScrollView.

First of all make sure you have provided a ScrollView in your xml layout.

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

...

</ScrollView>

然后在你的 activity 中确保你正在做这样的事情(这段代码只是为了演示在哪里使用 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);):

Then inside your activity make sure you are doing something like this(this code is just to demonstrate where to use getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);) :

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) {
            date.requestLayout();
            MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

            return false;
        }
    });
     }

这篇关于android:windowSoftInputMode=“adjustPan"不管用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)