Android soft keyboard covers edittext field

2018-12-31 13:25发布

Is there a way to make the screen scroll to allow the text field to be seen?

10条回答
骚的不知所云
2楼-- · 2018-12-31 13:53

I believe that you can make it scroll by using the trackball, which might be achieved programmatically through selection methods eventually, but it's just an idea. I know that the trackball method typically works, but as for the exact way to do this and make it work from code, I do not sure.
Hope that helps.

查看更多
不流泪的眼
3楼-- · 2018-12-31 13:54

Why not try to add a ScrollView to wrap whatever it is you want to scroll. Here is how I have done it, where I actually leave a header on top which does not scroll, while the dialog widgets (in particular the EditTexts) scroll when you open soft keypad.

<LinearLayout android:id="@+id/HeaderLayout" >
  <!-- Here add a header or whatever will not be scrolled. -->
</LinearLayout>
<ScrollView android:id="@+id/MainForm" >
  <!-- Here add your edittexts or whatever will scroll. -->
</ScrollView>

I would typically have a LinearLayout inside the ScrollView, but that is up to you. Also, setting Scrollbar style to outsideInset helps, at least on my devices.

查看更多
忆尘夕之涩
4楼-- · 2018-12-31 13:56

Are you asking how to control what is visible when the soft keyboard opens? You might want to play with the windowSoftInputMode. See developer docs for more discussion.

查看更多
高级女魔头
5楼-- · 2018-12-31 14:01

All you need to do is

android:isScrollContainer="true"

source: http://www.davidwparker.com/2011/08/25/android-fixing-window-resize-and-scrolling/

查看更多
柔情千种
6楼-- · 2018-12-31 14:01

Sorry for reviving an old thread but no one mentioned setting android:imeOptions="flagNoFullscreen" in your EditText element

查看更多
一个人的天荒地老
7楼-- · 2018-12-31 14:01

Edit your AndroidManifest.xml

android:windowSoftInputMode="adjustResize"

Add this to your root view of Layout file.

android:fitsSystemWindows="true"

That's all.

查看更多
登录 后发表回答