简体   繁体   English

如何在 Android 上调整键盘焦点布局?

[英]How to adjust keyboard foucus layout on Android?

This is my keyboard zoomin view when i click the edit text.这是我单击编辑文本时的键盘放大视图。 在此处输入图像描述

Problem is:问题是:

  1. It is way too big only one small strip of edit text is enough.它太大了,只有一小条编辑文本就足够了。
  2. Keyboard sometimes floating sometimes docking dont know what controls it.键盘有时浮动有时对接不知道是什么控制它。
  3. No need of that finish button and green line不需要那个完成按钮和绿线
  4. What is the callback function once the input in done一旦输入完成,回调 function 是什么

This is the method request soft keyboard popup这是请求软键盘弹出的方法

    public void editText(){
       Toast.makeText(mContext, "Editing Text",Toast.LENGTH_SHORT).show();
       InputMethodManager imm = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
       mEditText.setVisibility(VISIBLE);
       mEditText.requestFocus();
       mEditText.setText(mText);
       imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
    }

Properties of edit text编辑文本的属性

<EditText
    android:id="@+id/edit_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:hint="annotation text"
    android:inputType="text"
    android:textSize="14sp"
    android:visibility="gone"/>

It a default layout when you change your device orientation to landscape.当您将设备方向更改为横向时,它是默认布局。

Add添加

android:imeOptions="flagNoExtractUi|flagNoFullscreen"

to disable the fullscreen editing view禁用全屏编辑视图

<EditText
    android:id="@+id/edit_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:imeOptions="flagNoExtractUi|flagNoFullscreen"
    android:hint="annotation text"
    android:inputType="text"
    android:textSize="14sp"/>

flagNoExtractUi Used to specify that the IME does not need to show its extracted text UI. flagNoExtractUi用于指定 IME 不需要显示其提取的文本 UI。 For input methods that may be fullscreen, often when in landscape mode, this allows them to be smaller and let part of the application be shown behind.对于可能是全屏的输入法,通常在横向模式下,这允许它们更小,并让部分应用程序显示在后面。 Though there will likely be limited access to the application available from the user, it can make the experience of a (mostly) fullscreen IME less jarring.尽管用户对应用程序的访问可能会受到限制,但它可以使(大部分)全屏 IME 的体验不那么刺耳。 Note that when this flag is specified the IME may not be set up to be able to display text, so it should only be used in situations where this is not needed.请注意,当指定此标志时,IME 可能无法设置为能够显示文本,因此它应该只在不需要的情况下使用。

flagNoFullscreen Used to request that the IME never go into fullscreen mode. flagNoFullscreen用于请求 IME 永远不要 go 进入全屏模式。 Applications need to be aware that the flag is not a guarantee, and not all IMEs will respect it.应用程序需要知道该标志不是保证,并且并非所有 IME 都会尊重它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM