3

我正在全屏模式下开发 Android 应用程序。我希望在显示软输入时自动调整屏幕。我正在使用 ScrollView 使我的屏幕可以扩展到大于最大高度。您可以在下面看到布局 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="${packageName}.${activityClass}" >

    <VideoView
        android:id="@+id/taskdetail_bgvideo"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

    <ScrollView
        android:id="@+id/taskdetail_scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <!-- Other Widgets -->

        </LinearLayout>
    </ScrollView>
</RelativeLayout>

背景中的 VideoView 按预期放置,以在整体布局中创建背景视频。

当软键盘可见时,我尝试了Android How to adjust layout in Full Screen Mode 中的解决方法,但在我的情况下,它无法按预期工作。当我选择最底部的 TextView 时,所有屏幕都以某种方式向上推到顶部,在软键盘和活动屏幕之间留下了一个很大的黑色区域。检查下面的截图(对不起,信誉仍然很低,所以不能直接发布图片:()

巨大的黑洞

那么你有什么可能的想法来解决这种奇怪的行为吗?此外,我还尝试将 softInputMode 设置为 ADJUST_RESIZE 或 ADJUST_PAN,这两个设置都做到了。当我将它设置为 ADJUST_NOTHING 时,根本没有任何调整。

当我不使用上面提到的解决方法时,我无法将视图滚动到最底部的小部件,但不知何故,窗口视图被平移到聚焦的 TextView。我相信这实际上是罪魁祸首,但我不知道如何解决它。

提前致谢 :)

4

4 回答 4

9

如果您<item name="windowFullscreen">true</item>的主题中有该属性,则该属性android:windowSoftInputMode="adjustResize"不起作用。

于 2015-08-27T10:03:20.413 回答
0

尝试改变

<ScrollView
    android:id="@+id/taskdetail_scroll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

<ScrollView
    android:id="@+id/taskdetail_scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
于 2014-05-11T18:53:05.050 回答
-1

你必须写

android:windowSoftInputMode="stateHidden|adjustPan"

在您的清单文件中

于 2014-05-12T04:26:16.843 回答
-1

尝试将以下属性添加到您的<activity tag declarationinAndroidManifest.xml

android:windowSoftInputMode="stateHidden|adjustPan"
于 2014-05-12T04:08:13.903 回答