【问题标题】:Change size of Listview when closing or opening Softkeyboard关闭或打开软键盘时更改列表视图的大小
【发布时间】:2016-02-08 23:30:27
【问题描述】:

当我关闭或再次打开软键盘时如何展开我的列表视图?我的列表视图目前已全屏显示。

问题:当我想滚动到 ListView 的最后一项时,我必须先关闭软键盘,因为软键盘隐藏了它(所以它在软键盘下面),这有点烦人。

我在android音乐播放器搜索功能中找到了一个我想要实现的示例,当我打开和关闭它时看起来像这样(参见滚动条)

有没有办法没有太多的黑客攻击?我已经在我的清单中尝试过这个:

android:windowSoftInputMode="adjustResize"

但这没有帮助。

编辑: 我的布局:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/listview_background">

    <RelativeLayout
        android:id="@+id/RelativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:background="@color/colorPrimary"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/editText_searchbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/imageView_btn_back"
            android:ems="10"
            android:hint=" Search"
            android:singleLine="true"
            android:textColor="#FFFFFF"
            android:drawableBottom="#FFFFFF"
            android:textColorHint="#FFFFFF" >

            <requestFocus />
        </EditText>

        <ImageView
            android:id="@+id/imageView_btn_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/editText_searchbox"
            android:layout_alignParentLeft="true"
            android:layout_alignTop="@+id/editText_searchbox"
            android:src="@drawable/ic_chevron_left_white_48dp" 
            android:onClick="btn_back"/>

    </RelativeLayout>

    <ListView
        android:id="@+id/listView_results"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:fastScrollEnabled="true"
        android:smoothScrollbar="true"
        android:focusable="false"
        android:drawSelectorOnTop="true"
        android:gravity="top"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:layout_below="@+id/RelativeLayout1">
    </ListView>

</RelativeLayout>

【问题讨论】:

  • 试试adjustPan?我认为是滚动输入模式
  • 已经尝试过了,但它不起作用......还有其他建议吗?
  • 你能发布你的布局文件吗?
  • 我的帖子更新了。感谢您的帮助

标签: android listview size


【解决方案1】:

在 zgc7009 的帮助下,我发现 adjustResize 仅在布局为 NOT 全屏模式时才有效。这通过改变我的 AppTheme 风格解决了所有问题。

如果有人知道如何在全屏模式下使用adjustResize,请告诉我。

再次感谢zgc7009!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-11
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    相关资源
    最近更新 更多