【问题标题】:Android: Listview not shifting up with keyboardAndroid:Listview不使用键盘向上移动
【发布时间】:2011-09-22 04:39:56
【问题描述】:

我的布局是这样的:

<LinearLayout>
  <RelativeLayout>
    Some Image and Text as Title
  </RelativeLayout>
  <RelativeLayout>
    <LinearLayout>
      <ListView>
        My message List
      </ListView>
    </LinearLayout>
    <RelativeLayout>
      Edit Box and Send Button
    </RelativeLayout>
  </RelativeLayout>
</LinearLayout>

我在显示时明确将当前选择设置为列表的最后一项(最新)。

在底部的编辑框中不输入文本时,屏幕如下所示:

Top Title
  List Item 8
  List Item 7
  ...
  List Item 2
  List Item 1
  Bottom Edit box and Send Button

当我点击编辑框输入我的信息时,屏幕如下所示:

Top Title
  List Item 8
  ...
  List Item 5
  Bottom Edit Box and Send Button
  Keyboard

我真正想要的是:

Top Title
  List Item 4
  ...
  List Item 1
  Bottom Edit Box and Send Button
  Keyboard

有人可以帮帮我吗?

【问题讨论】:

    标签: android listview keyboard android-edittext


    【解决方案1】:

    我找到了答案here

    基本上只是用您的自定义类扩展 ListView,将 onSizeChanged() 方法重写为 setSelection(getCount());

    这似乎是最好的解决方案,而且 Google Voice 似乎使用了相同的策略(因为如果你在聊天列表的顶部,然后旋转屏幕,它会让你回到底部)。

    还要记住 android:windowSoftInputMode="adjustResize" 在清单中的 Activity 标记中出现,而不是 adjustPan。

    【讨论】:

      【解决方案2】:

      你试过this吗?

      您需要在列表中使用setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL)setStackFromBottom(true)。希望它有所帮助,它对我有用!

      【讨论】:

        猜你喜欢
        • 2018-01-12
        • 2015-09-23
        • 1970-01-01
        • 2018-07-19
        • 1970-01-01
        • 1970-01-01
        • 2011-07-10
        • 2018-06-02
        • 2015-12-22
        相关资源
        最近更新 更多