我正在做的就是在鍵盤打開時執行滾動!當鍵盤出現時,我的螢屏沒有向上滾動。我希望我的螢屏需要在鍵盤出現時向上滾動。以及它向我展示布局的底部。請提出滿足該要求的指導方針。有沒有其他方法可以做到這一點?..... 提前致謝。
我已經嘗試了很多 - 在清單檔案中放入該片段:
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" />
uj5u.com熱心網友回復:
你只需要使用adjustPan未adjustResize在相應的活動AndroidManifest.xml。你只需要像這樣調整它。
<activity
android:name=".work.CreateClassActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme.NoActionBar" />
uj5u.com熱心網友回復:
解決方案 - 步驟 - 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.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/403860.html
標籤:
