【问题标题】:Android Full Screen resize when soft input is shown显示软输入时Android全屏调整大小
【发布时间】:2014-05-11 17:24:22
【问题描述】:

我正在开发一个全屏模式的 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。我相信这实际上是罪魁祸首,但我不知道如何解决它。

提前致谢:)

【问题讨论】:

    标签: android android-layout android-fullscreen


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      尝试改变

      <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" >
      

      【讨论】:

      • 试试这个.. 把 ScrollView 作为根元素,听起来像..
      【解决方案3】:

      你必须写

      android:windowSoftInputMode="stateHidden|adjustPan"
      

      在您的清单文件中

      【讨论】:

        【解决方案4】:

        尝试在AndroidManifest.xml 中将以下属性添加到您的&lt;activity tag declaration

        android:windowSoftInputMode="stateHidden|adjustPan"
        

        【讨论】:

        • 不幸的是,它没有按我的预期工作。我不想在显示键盘时平移屏幕。我希望它将活动屏幕大小调整为软键盘上方的可用区域。但是因为activity是全屏的,所以adjustResize就不起作用了。
        猜你喜欢
        • 2015-11-04
        • 2019-07-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-10
        • 2014-11-01
        • 2019-03-19
        相关资源
        最近更新 更多