gpt4 book ai didi

android - AndroidX中的持久性 Bottom Sheet

转载 作者:行者123 更新时间:2023-12-03 10:12:13 28 4
gpt4 key购买 nike

layout_behavior - android.support.design.widget.BottomSheetBehavior is not working

this view is not constrained vertically at runtime it will jump



我仅在Androidx中收到此错误。因此,我如何解决此错误。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:background="#efefef"
tools:context=".MainActivity">


<include layout="@layout/content_main" />

<!-- Adding bottom sheet after main content -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="vertical"
android:padding="10dp"
app:behavior_hideable="true"
app:behavior_peekHeight="56dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

...... child layouts..


</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

enter image description here

最佳答案

由于您使用的是androidx库,因此必须使用Material Components Library
使用类 com.google.android.material.bottomsheet.BottomSheetBehavior 而不是android.support.design.widget.BottomSheetBehavior:

<LinearLayout     
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
..>

或者:
   <LinearLayout     
app:layout_behavior="@string/bottom_sheet_behavior"
..>

还要将 ConstraintLayout更改为 CoordinatorLayout

关于android - AndroidX中的持久性 Bottom Sheet ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59279683/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com