小编Pao*_*man的帖子

如何防止BottomAppBar重叠内容

我想使用 CoordinatorLayout 在屏幕底部包含一个 BottomAppBar,并在剩余空间中显示一些内容(例如使用 ConstraintLayout)。

如果我向 CoordinatorLayout 添加一个 ConstraintLayout,然后我添加一个放置在 ConstraintLayout 底部的按钮,则该按钮被 BottomAppBar 覆盖。

我希望 ConstraintLayout 用完所有垂直空间,除了 BottomAppBar 所在的位置,这样按钮就不会被覆盖。

我尝试在 ConstraintLayout 中包含 app:layout_behavior="@string/appbar_scrolling_view_behavior",正如某些网站所建议的那样,但它不起作用。另外,在BottomAppBar 中设置app:layout_insetEdge="bottom",然后在ConstraintLayout 中设置app:layout_dodgeInsetEdges="bottom" 也不能正常工作,因为ConstraintLayout 然后在屏幕顶部溢出(但底部没有被覆盖)不再)。

下面是 xml 布局文件,其中BottomAppBar 覆盖了按钮。谢谢

    <?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/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="top"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <Button
        android:id="@+id/myButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        style="@style/Widget.MaterialComponents.BottomAppBar.Colored"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom" />    
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

BottomAppBar 覆盖按钮

xml android android-layout android-bottomappbar

8
推荐指数
1
解决办法
328
查看次数

如何在Python中计算稀疏矩阵的零空间/内核(x:M·x = 0)?

我在网上找到了一些示例,展示了如何在Python中找到常规矩阵的零空间,但我找不到稀疏矩阵(scipy.sparse.csr_matrix)的任何示例.

零空间是指x使得M·x = 0,其中' · '是矩阵乘法.有人知道怎么做这个吗?

此外,在我的情况下,我知道零空间将由单个向量组成.这些信息可以用来提高方法的效率吗?

python numpy linear-algebra scipy sparse-matrix

6
推荐指数
1
解决办法
1159
查看次数

如果我设置一个现有的vector = vector <int>(num),我会得到内存泄漏吗?

如果我在C++中执行以下操作会发生什么:

vector<int> vect;
vect = vector<int>(8);
vect = vector<int>(3);
Run Code Online (Sandbox Code Playgroud)

第二行中分配的八个整数是否会在最后一行被删除,还是会被分配但丢失?(即内存泄漏)

c++ memory-leaks vector

2
推荐指数
1
解决办法
63
查看次数