键盘打开时片段布局无法完全滚动

问题描述

我希望片段中的布局能够完全滚动并在键盘打开时将其放置在软键盘上方。但是问题是当用户单击键盘时,布局甚至没有滚动。它覆盖了布局的一部分。

我已经尝试了许多SO线程,但是似乎没有一个工作。

这是活动布局:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.view.View" />

        <variable
            name="viewmodel"
            type="com.abc.viewmodel" />
    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".home.HomeActivity">

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/taskBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_minus10sdp"
            android:background="@android:color/white"
            app:cardCornerRadius="@dimen/_5sdp">

            
        </com.google.android.material.card.MaterialCardView>

        <LinearLayout
            android:id="@+id/appbar_practice"
            android:visibility="gone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorPrimaryDark"
            android:gravity="center_horizontal"
            android:orientation="horizontal"
            android:paddingTop="@dimen/_10sdp">

            
        </LinearLayout>

        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

</layout>

这是片段布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:isScrollContainer="true"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:animateLayoutChanges="true"
    android:background="@drawable/ic_bg_splash"
    android:fillViewport="true"
    android:paddingBottom="@dimen/_10sdp">
    
    <LinearLayout
        android:id="@+id/cardview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2">

            <ImageButton
                android:id="@+id/prevIoUs"
                android:layout_width="@dimen/_30sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="@dimen/_20sdp"
                android:background="@drawable/left"
                android:padding="@dimen/_5sdp" />
        </RelativeLayout>        

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2">

            <ImageButton
                android:id="@+id/next"
                android:layout_width="@dimen/_30sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="@dimen/_20sdp"
                android:background="@drawable/right" />

        </RelativeLayout>

    </LinearLayout>
</ScrollView>

清单:

 <activity android:name=".home.MainActivity"
            android:screenorientation="landscape"
            android:theme="@style/MaterialThemeHome"></activity>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...