显示软输入时,Android全屏调整大小

时间:2014-05-11 17:24:23

标签: android android-layout android-fullscreen

我正在以全屏模式开发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 when softkeyboard is visible中的解决方法,但在我的情况下,它并没有按预期工作。当我选择最底层的TextView时,所有屏幕都会以某种方式向上推到顶部,在软键盘和活动屏幕之间留下一个非常大的黑色区域。检查下面的截图(抱歉,信誉仍然很低,因此无法直接发布图像:()

Giant blackhole

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

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

提前致谢:)

3 个答案:

答案 0 :(得分: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" >

答案 1 :(得分:-1)

尝试将以下属性添加到<activity tag declaration

中的AndroidManifest.xml
android:windowSoftInputMode="stateHidden|adjustPan"

答案 2 :(得分:-1)

你必须写

android:windowSoftInputMode="stateHidden|adjustPan"
清单文件中的

相关问题