我正在做的就是在键盘打开时执行滚动!当键盘出现时,我的屏幕没有向上滚动。我想当键盘出现时,我的屏幕需要向上滚动。它还向我展示了布局的底部。请提出满足该要求的指导方针。有其他办法做那件事吗?。。。。。提前谢谢。
我试过很多-在清单文件中放入该片段:
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>
这是我的清单文件片段:
<activity
android:name=".work.CreateClassActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustResize|stateHidden"
android:theme="@style/AppTheme.NoActionBar" />
您只需要在AndroidManifest.xml
中的相应活动上使用adjustPan
而不是adjustResize
。你只需要像这样调整它。
<activity
android:name=".work.CreateClassActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme.NoActionBar" />
解决方案-步骤1:在清单文件中,将该行放在您的特定活动中:android:windowSoftInputMode=";adjustResize";
Step - 2 : In java file and in onCreate() put that line :
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Step - 3 : Before run the project - first clean project and uninstall previous apk.
Step - 4 : Run the project and you will get that desired result.