android - 带有BottomSheet的windowSoftInputMode不起作用
问题描述
我有BottomSheet
一个EditText
,当键盘出现时,BottomSheet
应该越过键盘。
所以我添加到Manifest.xml
:android:windowSoftInputMode="stateVisible|adjustResize"
或adjustPan
但是正如你在图片中看到的键盘越过BottomSheet
.
的代码BottomSheet
:
bottomSheetViewNewPocketItem = findViewById(R.id.bottomSheetNewPocketItem);
// BottomSheet new pocket item
bottomSheetBehaviorNewPocketItem = BottomSheetBehavior.from(bottomSheetViewNewPocketItem);
bottomSheetBehaviorNewPocketItem.setPeekHeight(200);
bottomSheetBehaviorNewPocketItem.setHideable(true);
我的清单如下所示:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/CoinMasterTheme">
<activity
android:name=".PocketMain"
android:label="@string/app_name"
android:windowSoftInputMode="stateVisible|adjustResize"
android:theme="@style/CoinMasterTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
和activity_pocket_main.xml
:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:id="@+id/coordinatorLayoutPocketMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context=".PocketMain">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:toolbarId="@+id/toolbar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginTop="22dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_pocket_main" />
<androidx.core.widget.NestedScrollView
android:id="@+id/bottomSheetNewPocketItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
android:fillViewport="true"
app:layout_behavior="@string/bottom_sheet_behavior">
<include layout="@layout/content_bottomsheet_new_pocket_item" />
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
解决方案
推荐阅读
- mysql - 如何在 if 块中使用 taxItem 和 Uom
- json - 使用 Codable 从 JSON 解析嵌套数据
- r - 具有不平衡数据的面板校正标准误差估计 (pcse) 模型
- javascript - AngularJS ngRequired 自定义指令
- azure-active-directory - 我们是否可以有两种不同的身份验证方式并仍然实现 SSO
- flutter - 颤动:无法获取特定索引或选择转到另一个页面
- c# - 如何计算AR点云数?(Unity AR 基金会 3.0.1)
- sql-server - SQL Server 透视文本值
- php - 在 wordpress 中调用未定义的函数 imagecreatefromwebp
- sql - 我正在尝试每年进行交易的总和或计数,我有这个代码,但我需要帮助才能让它正确