【发布时间】:2022-01-19 09:41:17
【问题描述】:
我正在努力在键盘打开时执行滚动!出现键盘时,我的屏幕没有向上滚动。当键盘出现时,我希望我的屏幕需要向上滚动。以及它向我展示了布局的底部。请提出满足该要求的指导方针。有没有其他方法可以做到这一点?.....提前谢谢。
我已经尝试了很多 - 在清单文件中放那个 sn-p :
android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="adjustResize|stateHidden"
在 XML 文件中添加属性:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/appBarLayout"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbars="none">
但是,这也不起作用。请提出任何适当的解决方案。
这是我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".work.CreateClassActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/ColorsWhite"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:weightSum="1"
app:popupTheme="@style/AppTheme.PopupOverlay">
<RelativeLayout
android:id="@+id/relativeLayoutLogo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.00"
android:visibility="visible">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="@string/create_class"
android:textColor="@color/colorTextDarkBlue"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/appBarLayout"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:weightSum="5">
</LinearLayout>
</ScrollView>
</RelativeLayout>
这是我的清单文件 sn-p:
<activity
android:name=".work.CreateClassActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustResize|stateHidden"
android:theme="@style/AppTheme.NoActionBar" />
【问题讨论】:
标签: android android-layout scrollview android-softkeyboard