Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >约束滚动视图内的布局不是滚动

在我的项目中,当我在滚动视图中放置约束布局时,不会滚动,约束布局是固定的。这是我的xml布局:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
    <?xml version="1.0" encoding="utf-8"?>
<layout 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"
    xmlns:williamchart="http://schemas.android.com/apk/res-auto">

    <data>

    </data>

    <androidx.drawerlayout.widget.DrawerLayout
        android:id="@+id/mdrawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:foregroundGravity="right"
        android:layoutDirection="rtl">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/back">


            <androidx.appcompat.widget.Toolbar
                android:id="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:alpha="0.77"
                android:background="#12315C"
                android:gravity="right"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    android:gravity="right"
                    android:orientation="vertical"
                    tools:layout_editor_absoluteX="16dp"
                    tools:layout_editor_absoluteY="14dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">


                        <ImageView
                            android:id="@+id/hammenu"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentStart="true"
                            android:layout_alignParentTop="true"
                            android:paddingTop="6dp"
                            android:src="@drawable/hammenu" />

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_alignParentTop="true"
                            android:layout_marginTop="0dp"
                            android:foregroundGravity="center_vertical|center|center_horizontal"
                            android:gravity="center|center_horizontal|center_vertical"
                            android:text="بازارها"
                            android:textColor="@android:color/background_light"
                            android:textSize="18dp"
                            android:textStyle="bold" />
                    </RelativeLayout>
                </LinearLayout>
            </androidx.appcompat.widget.Toolbar>

            <ScrollView
                android:id="@+id/scroll"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginTop="8dp"

                android:fillViewport="true"
                android:isScrollContainer="true"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/app_bar"
                williamchart:layout_constraintEnd_toEndOf="parent"
                williamchart:layout_constraintStart_toStartOf="parent">


                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:animateLayoutChanges="true"
                    android:isScrollContainer="true"
                    android:nestedScrollingEnabled="true"
                    android:orientation="vertical">


                    <com.google.android.material.card.MaterialCardView
                        android:id="@+id/materialcardview8"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="16dp"
                        app:layout_constraintStart_toStartOf="parent"
                        williamchart:cardBackgroundColor="@android:color/transparent"
                        williamchart:cardCornerRadius="32dp"
                        williamchart:layout_constraintHeight_percent="0.25"
                        williamchart:layout_constraintTop_toBottomOf="@+id/materialcardview6"
                        williamchart:layout_constraintWidth_percent="0.4">

                        <io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
                            android:id="@+id/blurLayout7"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            blurkit:blk_downscaleFactor="0.30"
                            blurkit:blk_fps="0" />


                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                            <ImageView
                                android:id="@+id/imageView7"
                                android:layout_width="0dp"
                                android:layout_height="0dp"
                                android:layout_marginStart="8dp"
                                android:layout_marginTop="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="8dp"
                                android:elevation="4dp"
                                williamchart:layout_constraintBottom_toBottomOf="parent"
                                williamchart:layout_constraintDimensionRatio="h,15:9"
                                williamchart:layout_constraintEnd_toEndOf="parent"
                                williamchart:layout_constraintStart_toStartOf="parent"
                                williamchart:layout_constraintTop_toTopOf="parent"
                                williamchart:srcCompat="@drawable/mypardis" />
                        </androidx.constraintlayout.widget.ConstraintLayout>

                    </com.google.android.material.card.MaterialCardView>

                    <com.google.android.material.card.MaterialCardView
                        android:id="@+id/materialcardview6"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="16dp"
                        app:layout_constraintStart_toStartOf="parent"
                        williamchart:cardBackgroundColor="@android:color/transparent"
                        williamchart:cardCornerRadius="32dp"
                        williamchart:layout_constraintHeight_percent="0.25"
                        williamchart:layout_constraintTop_toBottomOf="@+id/materialcardview4"
                        williamchart:layout_constraintWidth_percent="0.4">

                        <io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
                            android:id="@+id/blurLayout5"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            blurkit:blk_downscaleFactor="0.30"
                            blurkit:blk_fps="0" />


                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                            <ImageView
                                android:id="@+id/imageView5"
                                android:layout_width="0dp"
                                android:layout_height="0dp"
                                android:layout_marginStart="8dp"
                                android:layout_marginTop="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="8dp"
                                android:elevation="4dp"
                                williamchart:layout_constraintBottom_toBottomOf="parent"
                                williamchart:layout_constraintDimensionRatio="h,15:9"
                                williamchart:layout_constraintEnd_toEndOf="parent"
                                williamchart:layout_constraintStart_toStartOf="parent"
                                williamchart:layout_constraintTop_toTopOf="parent"
                                williamchart:srcCompat="@drawable/mypardis" />
                        </androidx.constraintlayout.widget.ConstraintLayout>

                    </com.google.android.material.card.MaterialCardView>


                    <com.google.android.material.card.MaterialCardView
                        android:id="@+id/materialcardview4"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="16dp"
                        app:layout_constraintStart_toStartOf="parent"
                        williamchart:cardBackgroundColor="@android:color/transparent"
                        williamchart:cardCornerRadius="32dp"
                        williamchart:layout_constraintHeight_percent="0.25"
                        williamchart:layout_constraintTop_toBottomOf="@+id/materialcardview2"
                        williamchart:layout_constraintWidth_percent="0.4">

                        <io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
                            android:id="@+id/blurLayout3"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            blurkit:blk_downscaleFactor="0.30"
                            blurkit:blk_fps="0" />


                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                            <ImageView
                                android:id="@+id/imageView3"
                                android:layout_width="0dp"
                                android:layout_height="0dp"
                                android:layout_marginStart="8dp"
                                android:layout_marginTop="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="8dp"
                                android:elevation="4dp"
                                williamchart:layout_constraintBottom_toBottomOf="parent"
                                williamchart:layout_constraintDimensionRatio="h,15:9"
                                williamchart:layout_constraintEnd_toEndOf="parent"
                                williamchart:layout_constraintStart_toStartOf="parent"
                                williamchart:layout_constraintTop_toTopOf="parent"
                                williamchart:srcCompat="@drawable/mypardis" />
                        </androidx.constraintlayout.widget.ConstraintLayout>

                    </com.google.android.material.card.MaterialCardView>

                    <com.google.android.material.card.MaterialCardView
                        android:id="@+id/materialcardview2"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="16dp"
                        app:layout_constraintStart_toStartOf="parent"
                        williamchart:cardBackgroundColor="@android:color/transparent"
                        williamchart:cardCornerRadius="32dp"
                        williamchart:layout_constraintHeight_percent="0.25"
                        williamchart:layout_constraintTop_toTopOf="parent"
                        williamchart:layout_constraintWidth_percent="0.4">

                        <io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
                            android:id="@+id/blurLayout1"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            blurkit:blk_downscaleFactor="0.30"
                            blurkit:blk_fps="0" />


                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                            <ImageView
                                android:id="@+id/imageView1"
                                android:layout_width="0dp"
                                android:layout_height="0dp"
                                android:layout_marginStart="8dp"
                                android:layout_marginTop="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="8dp"
                                android:elevation="4dp"
                                williamchart:layout_constraintBottom_toBottomOf="parent"
                                williamchart:layout_constraintDimensionRatio="h,15:9"
                                williamchart:layout_constraintEnd_toEndOf="parent"
                                williamchart:layout_constraintStart_toStartOf="parent"
                                williamchart:layout_constraintTop_toTopOf="parent"
                                williamchart:srcCompat="@drawable/mypardis" />
                        </androidx.constraintlayout.widget.ConstraintLayout>

                    </com.google.android.material.card.MaterialCardView>

                    <com.google.android.material.card.MaterialCardView
                        android:id="@+id/materialCardView"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_marginTop="16dp"
                        android:layout_marginEnd="8dp"
                        app:cardBackgroundColor="@android:color/transparent"
                        app:cardCornerRadius="32dp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHeight_percent="0.25"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintWidth_percent="0.4">

                        <io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
                            android:id="@+id/blurLayout2"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            blurkit:blk_downscaleFactor="0.30"
                            blurkit:blk_fps="0" />

                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                            <ImageView
                                android:id="@+id/imageView2"
                                android:layout_width="0dp"
                                android:layout_height="0dp"
                                android:layout_marginStart="8dp"
                                android:layout_marginTop="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="8dp"
                                android:elevation="4dp"
                                app:layout_constraintBottom_toBottomOf="parent"
                                app:layout_constraintDimensionRatio="h,15:9"
                                app:layout_constraintEnd_toEndOf="parent"
                                app:layout_constraintStart_toStartOf="parent"
                                app:layout_constraintTop_toTopOf="parent"
                                williamchart:srcCompat="@drawable/mypardis" />
                        </androidx.constraintlayout.widget.ConstraintLayout>

                    </com.google.android.material.card.MaterialCardView>

                </androidx.constraintlayout.widget.ConstraintLayout>
            </ScrollView>

        </androidx.constraintlayout.widget.ConstraintLayout>
        <com.google.android.material.navigation.NavigationView
            android:id="@+id/navigation"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="right" />
        <!--app:headerLayout="@layout/navigation_header"
        app:menu="@menu/drawermenu"-->



    </androidx.drawerlayout.widget.DrawerLayout>
</layout>

但当我将约束转换为线性时,效果很好。我搜索了很多主题,并在滚动视图中放入了android:fillViewport="true“,但是如果我把滚动视图放在根视图中,我的约束布局就不会滚动,这是可以的

EN

回答 1

Stack Overflow用户

发布于 2019-07-22 12:51:18

在viewport为true时使用NestedScrollView

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="700dp">

        </android.support.constraint.ConstraintLayout>

</androidx.core.widget.NestedScrollView>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57146130

复制
相关文章
useContext
Context是React提供的一种跨组件的通信方案,useContext与useReducer是在React 16.8之后提供的Hooks API,我们可以通过useContext与useReducer来完成全局状态管理例如Redux的轻量级替代方案。
WindRunnerMax
2022/09/29
9910
useTypescript-React Hooks和TypeScript完全指南
React v16.8 引入了 Hooks,它可以让你在不编写 class 的情况下使用 state 以及其他的 React 特性。这些功能可以在应用程序中的各个组件之间使用,从而易于共享逻辑。Hook 令人兴奋并迅速被采用,React 团队甚至想象它们最终将替换类组件。
前端森林
2020/04/23
8.6K0
useTypescript-React Hooks和TypeScript完全指南
BattlEye通讯挂钩
为了与广大视频游戏黑客作斗争,反作弊系统需要从客户那里收集和处理大量信息。通常,这通常是通过将所有内容发送到服务器进行进一步分析来完成的,这使攻击者可以通过有趣的方式规避这些系统,其中之一是劫持了通信例程。
franket
2021/02/09
3.9K0
useContext更佳实践
这么说的人可能忽视了state(状态)—— 不同于组件是以树的形式组合,我们经常会在不同层级的组件间公用同一个state。
公众号@魔术师卡颂
2020/08/26
8990
4.5 MinHook 挂钩技术
MinHook是一个轻量级的Hooking库,可以在运行时劫持函数调用。它支持钩子API函数和普通函数,并且可以运行在32位和64位Windows操作系统上。其特点包括易于使用、高性能和低内存占用。MinHook使用纯汇编语言实现,在安装和卸载钩子时只需要短暂地锁定目标线程,因此对目标线程的影响非常小。
微软技术分享
2023/10/11
3560
4.5 MinHook 挂钩技术
React-Hooks-useContext
useContext 是 React 中的一个 Hooks,它用于访问 React 上下文(Context),并允许您在函数组件中共享全局数据,避免了逐层传递 props 的麻烦。以下是关于 useContext 的简介:
杨不易呀
2023/10/01
1870
绕过 EDR 挂钩
通过修补 NT API 存根并在运行时解析 SSN 和系统调用指令来绕过 EDR 挂钩
Khan安全团队
2023/02/23
6130
绕过 EDR 挂钩
超性感的React Hooks(八)useContext
在context这个高级API出来之前,数据流向只能自上而下,从父组件一层一层的往下传递。如上图左。
用户6901603
2020/07/27
1.2K0
超性感的React Hooks(八)useContext
自定义类型的创建
 以上方法,对于有其他OO语言经验的开发人员去看,比较容易理解,但是性能上并不推荐。因为每次创建新的实例都需要进行一次判断,哪怕这次的性能损耗是极小的,但毕竟也是有损耗。
就只是小茗
2018/12/07
1.1K0
4.5 MinHook 挂钩技术
MinHook是一个轻量级的Hooking库,可以在运行时劫持函数调用。它支持钩子API函数和普通函数,并且可以运行在32位和64位Windows操作系统上。其特点包括易于使用、高性能和低内存占用。MinHook使用纯汇编语言实现,在安装和卸载钩子时只需要短暂地锁定目标线程,因此对目标线程的影响非常小。
微软技术分享
2023/09/18
5430
4.5 MinHook 挂钩技术
超性感的React Hooks(九)useContext实践
我们利用useContext来实现这个小demo。在实现之前,复习一下相关比较重要的知识点。
用户6901603
2020/07/27
1.4K0
超性感的React Hooks(九)useContext实践
内核挂钩调试记录
NTSTATUS Ioctl_DeviceControl(__in PDEVICE_OBJECT pDeviceObject, __in PIRP pIrp)
战神伽罗
2019/07/24
6040
Rust数组默认初始化:初始化未实现Copy trait的类型
在安全的Rust中,编译器要求数组一旦被声明,它所占用的内存应当被完全初始化。但是,在一些情况下,这样会导致没法很灵活的对数组进行默认初始化。
灯珑LoGin
2023/10/18
3880
Rust数组默认初始化:初始化未实现Copy trait的类型
4.3 IAT Hook 挂钩技术
IAT(Import Address Table)Hook是一种针对Windows操作系统的API Hooking 技术,用于修改应用程序对动态链接库(DLL)中导入函数的调用。IAT是一个数据结构,其中包含了应用程序在运行时使用的导入函数的地址。
微软技术分享
2023/09/15
9870
4.3 IAT Hook 挂钩技术
4.4 EAT Hook 挂钩技术
EAT(Export Address Table)用于修改动态链接库(DLL)中导出函数的调用。与IAT Hook不同,EAT Hook是在DLL自身中进行钩子操作,而不是修改应用程序的导入表。它的原理是通过修改DLL的导出函数地址,将原本要导出的函数指向另一个自定义的函数。这样,在应用程序调用DLL的导出函数时,实际上会执行自定义的函数。
微软技术分享
2023/09/15
2960
4.4 EAT Hook 挂钩技术
4.2 Inline Hook 挂钩技术
InlineHook 是一种计算机安全编程技术,其原理是在计算机程序执行期间进行拦截、修改、增强现有函数功能。它使用钩子函数(也可以称为回调函数)来截获程序执行的各种事件,并在事件发生前或后进行自定义处理,从而控制或增强程序行为。Hook技术常被用于系统加速、功能增强、开发等领域。本章将重点讲解Hook是如何实现的,并手动封装实现自己的Hook挂钩模板。
微软技术分享
2023/10/11
3460
4.2 Inline Hook 挂钩技术
Scala的自定义类型标记
Scala中有很多千奇百怪的符号标记,看起来是那么的独特,就像是一杯dry martini...好像黑夜中的萤火虫,那么耀眼,那么出众。
程序那些事
2020/07/08
8560
挂钩图形内核子系统
当今的作弊行为主要是使用内部Directx挂钩或窗口覆盖图来可视化隐藏的游戏信息。这两种方法已被广泛记录,但其他更不起眼的方法包括在Windows内核中挂接图形例程,正如我们将在本文中演示的那样。没有公开发布使用与此类似的方法,这很可惜,因为与普通的Directx钩子相比,它实际上非常易于使用并且几乎没有痕迹。
franket
2021/04/13
3.2K0
4.2 Inline Hook 挂钩技术
InlineHook 是一种计算机安全编程技术,其原理是在计算机程序执行期间进行拦截、修改、增强现有函数功能。它使用钩子函数(也可以称为回调函数)来截获程序执行的各种事件,并在事件发生前或后进行自定义处理,从而控制或增强程序行为。Hook技术常被用于系统加速、功能增强、开发等领域。本章将重点讲解Hook是如何实现的,并手动封装实现自己的Hook挂钩模板。
微软技术分享
2023/09/14
6460
4.2 Inline Hook 挂钩技术
4.4 EAT Hook 挂钩技术
EAT(Export Address Table)用于修改动态链接库(DLL)中导出函数的调用。与IAT Hook不同,EAT Hook是在DLL自身中进行钩子操作,而不是修改应用程序的导入表。它的原理是通过修改DLL的导出函数地址,将原本要导出的函数指向另一个自定义的函数。这样,在应用程序调用DLL的导出函数时,实际上会执行自定义的函数。
微软技术分享
2023/10/11
1700
4.4 EAT Hook 挂钩技术

相似问题

angular js指令-如何评估指令的模板html的角度标签

12

自定义指令:如何使用动态HTML评估绑定

11

将多个模板作为HTML注入指令并编译到指令范围

13

如何在评估javascript之前加载指令模板

12

AngularJS指令模板没有编译

11
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文