【发布时间】:2020-11-03 16:23:43
【问题描述】:
我需要使用Coordinatorlayout 才能让layout_behaviour attr 在滚动时隐藏FAB。
通常我只会将我的 FAB 放在底端,但这次我实现了可扩展的 fab,我发现很难在 Coordinatorlayout 中将 4 个 FABS 放在一个之上。
任何想法我能做什么?
我不介意以任何一种方式获得解决方案(在没有 Coordinatorlayout 的情况下处理隐藏在 API 23 下方的 webview 滚动上的晶圆厂,或者在 Coordinatorlayout 中正确地将晶圆厂放在彼此之上)
目前这是我的ConstraintLayout:
<?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">
<WebView
android:id="@+id/webView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</WebView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:focusable="true" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toTopOf="@+id/fab1"
app:layout_constraintEnd_toEndOf="@+id/fab1"
app:layout_constraintStart_toStartOf="@+id/fab1" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toTopOf="@+id/fab2"
app:layout_constraintEnd_toEndOf="@+id/fab2"
app:layout_constraintStart_toStartOf="@+id/fab2" />
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
-
你试过
android:layout_gravity="end|bottom"
标签: android android-layout kotlin