按列表视图时,键盘会出现不adjustPan [英] Push Listview when keyboard appears without adjustPan

查看:291
本文介绍了按列表视图时,键盘会出现不adjustPan的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个活动以列表视图,并在底部的发送消息。问题是,在键盘显示时,而不是推底部内容,只是它隐藏。我尝试使用adjustPan,但它推动了孔视图了(所以没有办法看到列表视图顶部的元素,也去动作条消失)。

I am trying to create an activity with a listview and a send message at bottom. The problem is that when the keyboard is shown, instead of pushing the bottom content, is just hiding it. I tried using adjustPan, but it pushes the hole view up (so there is no way to see the top elements of the listview and also de actionbar disappears).

如果你看一看的WhatsApp或线路,该功能是,当列表的最后一项显示在屏幕的下方,键盘向上推列表视图(不采取行动酒吧或第一要素了屏幕),并且当该列表的最后一个项目中未示出(后一些向上滚动)的键盘被隐藏底部列表(正常adjustResize)。

If you take a look at WhatsApp or Line, the functionality is that when the last item of the list is shown at the bottom of the screen, the keyboard pushes up the listview (without taking the action bar or the first elements out of the screen), and when the last item of the list is not shown (after some scrolling up) the keyboard is hidden the bottom list (a normal adjustResize).

任何人这个问题dealed?

Anyone dealed with this issue?

感谢

编辑:

我会尽力把一个可视化的例子:

I'll try to put a visual example:

因此​​,可以说这在ListView:

So lets say this the ListView:

---item 1---  
---item 2---  
---item 3---  
---item 4---  
---EditText---

的EDITTEXT不是在ListView的一部分,但在底部对准的的LinearLayout。当键盘显示,在ListView变成这样(项目3和4隐藏键盘):

The editText is not part of the ListView, but a LinearLayout aligned at the bottom. When keyboard is shown, the ListView becomes like this (Item 3 and 4 are hidden by Keyboard):

---item 1---  
---item 2---  
---EditText---
---Keyboard---  

和我想获得的是:

---item 3---  
---item 4---  
---EditText---
---Keyboard---  

我已经试过了android:windowSoftInputMode =adjustPan。而结果是用途不同的项目3和4被向上推,而不是通过键盘隐藏了。问题是,它推动列表视图,但它推动它的屏幕上,所以动作条消失,即使试图向上滚动,我从来没有看到项目1和2中所示的键盘。

I've tried the android:windowSoftInputMode="adjustPan".and the result is that effectivly item 3 and 4 are pushed up and not hidden by keyboard anymore. The problem is that it pushes the listview, but it pushes it out of the screen, so the actionBar disappears, and even if trying to scroll up, I can never see the Item 1 and 2 with the keyboard shown.

希望我解释自己,不是很容易的。

Hope I explained myself, not really easy..

感谢

推荐答案

好吧,我发现你的解决方案,你想做的事基本上每次都在ListView滚动至底部。你可以这样做:

Okay I have found a solution for you, what you want to do is essentially have the ListView scroll to the bottom every time. You can do this by:

ListView l = getListView();
l.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
l.setStackFromBottom(true);

如果它是一个活动,这样做在的onCreate 。如果是片段,这样做在 onViewCreated

If it is an Activity, do it in onCreate. If it is a Fragment, do it in onViewCreated.

这篇关于按列表视图时,键盘会出现不adjustPan的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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