gpt4 book ai didi

android - 出现 snackbar 时使 ScrollView 变小

转载 作者:行者123 更新时间:2023-11-29 14:44:05 27 4
gpt4 key购买 nike

我刚开始在我的 android 应用程序中使用 Snackbar,但我无法将 ScrollView 缩小到不覆盖 ScrollView 内部的任何内容。

这是我的 Activity 的 xml 布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
android:id="@+id/container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
tools:context="com.example.MainActivity">

<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:orientation="vertical">

[LOT OF ELEMENTS IN HERE]

</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>

我在 StackOverflow 上尝试了很多解决方案,但还没有一个对我有用。

最佳答案

我的猜测是,对您来说最好的解决方案是按照 page 中的规定实现 CoordinatorLayout ,如果你在链接中看到 GIF 格式,你可以看到当 SnackBar 被触发时 Floating Botton 如何升起的动画,尝试用 ScrollView 元素代替教程的 Floating Button,我想可以工作(ScrollView 应该是无论如何在其他属性之上..)

如果不起作用可能您想扩展 ScrollView 并覆盖您需要的方法,如 google official 中所述文档,这应该始终有效,但您需要多做一些工作。两种解决方案之一应该可以解决问题。

关于android - 出现 snackbar 时使 ScrollView 变小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47229385/

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