键盘显示时ScrollView不起作用

时间:2019-07-31 03:49:55

标签: java android scrollview relativelayout android-softkeyboard

我正在尝试实施一个简单的活动,以便用户可以对某些内容进行评分并发表评论。

我的看法是这样:

enter image description here

代码:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:background="@color/background_material_light"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:isScrollContainer="true"
        >
        <ImageView
            android:id="@+id/img_journey"
            android:layout_width="wrap_content"
            android:layout_height="250dp"
            android:src="@drawable/pirate"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:layout_alignParentTop="true" />

        <LinearLayout
            android:id="@+id/ratingLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_below="@+id/img_journey"
            android:layout_marginTop="10dp">

            <TextView
                android:id="@+id/title_journey"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Title"
                android:layout_gravity="center"
                android:textSize="30sp"
                android:textColor="@color/niceblue" />

            <RatingBar
                android:id="@+id/framework_normal_ratingbar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minHeight="48dp"
                android:maxHeight="48dp"
                android:rating="5"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/textbox_rate"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/button_layout"
            android:layout_below="@+id/ratingLayout"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginTop="25dp"
            android:layout_marginBottom="25dp">

            <EditText
                android:padding="10dp"
                android:gravity="start"
                android:background="@drawable/textbox"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:hint="@string/hint_comment"
                android:inputType="text"
                android:autofillHints="" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/button_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_alignParentBottom="true"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center|bottom"
                android:orientation="horizontal"
                android:weightSum="8"
                android:layout_marginBottom="40dp">
                <Button
                    android:id="@+id/btn_launch"
                    android:text="SEND RATE"
                    style="@style/button_classic"/>
            </LinearLayout>

        </LinearLayout>

    </RelativeLayout>
</ScrollView>

事实是,当我单击editText时显示键盘时,视图不可滚动,结果是这样的:

enter image description here

我在互联网上搜索了3个小时,但是却一无所获,我发现的唯一结果就是将其放在活动的onCreate上

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

但是它也不起作用。 (我尝试过是否带有每个标志)

我尝试过的第二件事是将ScrollView放入RelativeLayout中,但相同的结果不起作用。

我想要的是键盘出现在编辑文本的下方,并且我们看不到“发送速率”按钮(除非用户滚动),最后,即使键盘是显示。

我做错了什么还是什么?

谢谢!

0 个答案:

没有答案
相关问题