Android键盘覆盖编辑文本 [英] Android keyboard covering edit text

查看:109
本文介绍了Android键盘覆盖编辑文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网页编辑的文字,我需要调整屏幕显示的数值打字吧。

我在我的网页操作栏,我已经给的android:windowSoftInputMode =adjustPan | stateAlwaysHidden

当我运行的应用程序,我摸我的编辑文本和键盘弹出。编辑文本现在来在键盘的上方是正确的。但是,当我开始打字这个编辑文本下山键盘。

这并不适用于所有的设备发生。在三星S3其有这个问题。如何解决此问题?请帮助我。

编辑:

我的编辑分机code是如下:

 <的EditText
            机器人:ID =@ + ID /名称
            机器人:layout_width =300dp
            机器人:layout_height =50dp
            机器人:layout_below =@ + ID / EMPID
            机器人:layout_marginTop =10dp
            机器人:ellipsize =结束
            机器人:提示=@字符串/名
            安卓的inputType =TEXT
            机器人:MAXLINES =1
            机器人:填充=5DP
            机器人:文字颜色=@机器人:彩色/黑白/>


解决方案

我有类似的problem.what我所做的就是,iadded根布局像这样

下面的线性布局

 <的LinearLayout
        机器人:方向=垂直
        机器人:ID =@ + ID / footer_for_emoticons
        机器人:layout_width =match_parent
        机器人:layout_height =@扪/ keyboard_height
        机器人:知名度=水涨船高>
    < / LinearLayout中>

然后在活动

  activityRootView.getViewTreeObserver()。addOnGlobalLayoutListener(
                新OnGlobalLayoutListener(){
                    @覆盖
                    公共无效onGlobalLayout(){
                        矩形R =新的矩形();
                        activityRootView.getWindowVisibleDisplayFrame(R);                        INT heightDiff = activityRootView.getRootView()
                                .getHeight() - (r.bottom - r.top);
                        如果(lastDiff == heightDiff)
                            返回;
                        lastDiff = heightDiff;
                        Log.i(aerfin,arefin+ lastDiff);
                        如果(heightDiff→100){//假设键盘是present
                            emoticonsCover.setVisibility(View.VISIBLE);
                            FLAG2 = 0;
                        }其他{
                            如果(标志== FALSE)
                                FLAG2 = 1;
                               emoticonsCover.setVisibility(View.GONE);
                        }
                    }
                });

线性布局将提供的差距,并在清单中添加的android:到activity.Check windowSoftInputMode =adjustPan是否有利于

I have an edit text in my page and I need to adjust screen to show the values typing in it.

I have action bar in my page and I have given android:windowSoftInputMode="adjustPan|stateAlwaysHidden" .

When I run the app, I touch on my edit text and keyboard pops up. The edit text comes on top of the keyboard now which is right. But when I start typing this edit text goes down the keyboard.

This doesn't happen in all devices. In Samsung S3 its having this issue. How to solve this? Please help me out.

Edit:

My edit ext code is as below:

<EditText
            android:id="@+id/name"
            android:layout_width="300dp"
            android:layout_height="50dp"
            android:layout_below="@+id/empId"
            android:layout_marginTop="10dp"
            android:ellipsize="end"
            android:hint="@string/name"
            android:inputType="text"
            android:maxLines="1"
            android:padding="5dp"
            android:textColor="@android:color/black" />

解决方案

I had similar problem.what i did was , iadded a linear layout below the root layout like this

  <LinearLayout
        android:orientation="vertical"
        android:id="@+id/footer_for_emoticons"
        android:layout_width="match_parent"
        android:layout_height="@dimen/keyboard_height"
        android:visibility="gone" >
    </LinearLayout> 

Then in the activity

activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
                new OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        Rect r = new Rect();
                        activityRootView.getWindowVisibleDisplayFrame(r);

                        int heightDiff = activityRootView.getRootView()
                                .getHeight() - (r.bottom - r.top);
                        if (lastDiff == heightDiff)
                            return;
                        lastDiff = heightDiff;
                        Log.i("aerfin","arefin "+lastDiff);
                        if (heightDiff > 100) { //Assume keyboard is present 
                            emoticonsCover.setVisibility( View.VISIBLE );
                            flag2 = 0;
                        } else {
                            if (flag == false)
                                flag2 = 1;
                               emoticonsCover.setVisibility( View.GONE );
                        }
                    }
                });

The linear layout will provide the gap and in manifest add android:windowSoftInputMode="adjustPan" to the activity.Check whether it helps

这篇关于Android键盘覆盖编辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆