【问题标题】:Shrinking a ScrollView on resize for IME - what am I doing wrong?为 IME 调整大小时缩小 ScrollView - 我做错了什么?
【发布时间】:2012-05-01 10:42:57
【问题描述】:

我试图让下面的 ScrollView 缩小,以便在使用 IME 时,它上面的所有其他元素仍然可见,或者至少,让 ScrollView 的顶部向下移动到屏幕顶部。

Main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="match_parent"
    android:orientation="vertical" android:id="@+id/gameLayout">

    <TextView android:id="@+id/gameTitle" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:textColor="@color/Red"
        android:maxLines="1" />

    <ScrollView android:id="@+id/gameScroll"
        android:layout_width="match_parent" android:layout_height="fill_parent"
        android:fillViewport="false" android:layout_above="@+id/gameEntry"
        android:layout_below="@+id/gameTitle">

        <TextView android:id="@+id/gameText" android:layout_width="match_parent"
            android:layout_height="wrap_content" android:scrollbars="vertical" />

    </ScrollView>

    <AutoCompleteTextView android:id="@+id/gameEntry"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/gameSubmit"
        android:hint="@string/Hint" android:imeOptions="actionDone"
        android:lines="1" />


    <TextView android:id="@+id/gameSubmit" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_alignBaseline="@+id/gameEntry"
        android:layout_alignParentRight="true" android:gravity="center"
        android:text="@string/Submit" android:textColor="@color/Red"
        android:textSize="18dp" android:lines="1" />

</RelativeLayout>

这可以吗? 我可能犯了一些愚蠢的错误......哦,我做了他们在How to prevent that the keyboard hides my EditText?上推荐的所有内容

而且,我还在清单中添加了android:windowSoftInputMode="adjustResize",它仍在平移...提示 3..2..1 中的“哇,这是一个愚蠢的问题”......

【问题讨论】:

  • 你解决过这个问题吗?
  • 我不确定...我放弃了那个项目,因为那是一个学校项目。不过还是谢谢。

标签: android resize scrollview android-softkeyboard ime


【解决方案1】:

尝试将ScrollView 上的android:layout_height="fill_parent" 更改为android:layout_height="wrap_content",并将android:layout_above="@+id/gameEntry" 添加到ScrollView

【讨论】:

  • 谢谢,但没用。我有android:layout_above="@+id/gameEntry,我尝试过 wrap_content,但这也没有用。不过,谢谢。
猜你喜欢
  • 2010-10-16
  • 2017-08-25
  • 2017-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多