scrollview没有滚动到屏幕的底部

时间:2016-02-15 13:44:49

标签: android scrollview fullscreen

使用Theme.Black.NoTitleBar.Fullscreen时,我很难实现滚动视图。 当用户打开应用程序并单击editText时,键盘会打开,但用户无法在edittext下滚动。 经过多次尝试,我认为它与我正在使用的主题有关(全屏) 这是我的代码.xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:fillViewport="true"
 >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <View
        android:id="@+id/vieww"
        android:layout_width="match_parent"
        android:layout_height="1000dp"
        android:background="@android:color/holo_green_dark" />

    <EditText
        android:id="@+id/test_edit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/vieww" />

    <View
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_below="@id/test_edit"
        android:background="@android:color/holo_blue_bright" />
</RelativeLayout>

当键盘打开时,用户无法看到edittext下方的最低视图。

到目前为止我尝试了什么:

  1. 我用windowSoftInputMode玩了很多活动,我尝试了adjustResize / adjustPan的组合,但似乎没什么用。
  2. 我尝试将容器更改为LinearLayout,但它仍然不适合我
  3. 我在这里找到了一个解决方案here 这个解决方案的问题我需要将minSdk更改为19,当应用程序启动时,我可以看到黑条纹已经是标题栏。 另一个问题是当用户通过按下edittext打开键盘时标题栏返回

1 个答案:

答案 0 :(得分:0)

我认为您应该将ScrollView放在相对布局中,以便在键盘出现时可以调整大小。

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:fillViewport="true" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<View
    android:id="@+id/vieww"
    android:layout_width="match_parent"
    android:layout_height="1000dp"
    android:background="@android:color/holo_green_dark" />

<EditText
    android:id="@+id/test_edit"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/vieww" />

<View
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_below="@id/test_edit"
    android:background="@android:color/holo_blue_bright" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
相关问题