简体   繁体   English

Android软键盘隐藏按钮

[英]Android soft keyboard hides button

I do have a simple login view like shown below. 我有一个简单的登录视图,如下所示。

If any EditText gains focus, the keyboard will be shown (soft). 如果任何EditText获得焦点,将显示键盘(软)。 The red dashed line should outline this behavior: 红色虚线应勾勒出这种行为:

键盘

What I need is, that the Buttons at the bottom (Signup & Help) are invisible while Keyboard is showing. 我需要的是,键盘显示时,底部的按钮(注册和帮助)是不可见的 The bottom end of the login button should be over the keyboard, so that both EditTexts and the Login Button are visible. 登录按钮的底端应位于键盘上方,以便可以看到EditTexts Login Button

At best half of the Logo should be visible if possible (depending on screen size) 如果可能,最多应该看到徽标的一半(取决于屏幕尺寸)

It would be perfectly fine to define an extra layout xml like "keyboard is visible" if that's possible. 如果可能的话,定义一个额外的布局xml,如“键盘可见”,这将是完美的。

1) ScrollView as parent layout so that it can be scrolled by user. 1) ScrollView作为父布局,以便用户可以滚动它。

2) using only adjustResize 2)仅使用adjustResize

3) Use software keyboard show/hide event to have more control. 3)使用软件键盘显示/隐藏事件进行更多控制。 You can set visibility of the layout below login button with View.GONE while keyboard is visibe. 当键盘是visibe时,您可以使用View.GONE设置登录按钮下方布局的可见性。

extra: 额外:

Check Specifying the Input Method Type . 检查指定输入法类型 Next and Done actions for convenience of user 下一步和完成操作以方便用户

Do somthing like dis. 做像dis一样的事情。 Here "android:name" is your activity. 这里“android:name”是你的活动。

<activity
            android:name="com.example.tryitonjewelry.EnterStoreRegisterNew"
            android:label="@string/title_activity_enter_store_register_new"
            android:screenOrientation="portrait" 
            android:windowSoftInputMode="adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.ENTERSTOREREGISTERNEW" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

You can manage it by few steps. 您可以通过几个步骤进行管理。 When KeyBoard popup then do the following steps or you can wrap these in a method... KeyBoard弹出时,然后执行以下步骤,或者您可以将它们包装在方法中...

  1. Get the window height. 获得窗口高度。
  2. Determine the keyboard height. 确定键盘高度。
  3. Scroll your view above the keyboard height using scrollTo() method. 使用scrollTo()方法在键盘高度上滚动视图。

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

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