草庐IT

android - 约束布局在底部有额外的空间

coder 2023-12-28 原文

我正在实现一个在 ScrollView 中使用约束布局的 View 。我正在尝试使用 app:layout_constraintBottom_toBottomOf="parent 将 View 与父级的底部对齐但是,正如您在图片中看到的那样,我的 View 下方有额外的空白区域。蓝色 View 下方的空白区域.有人可以指导我如何删除底部多余的空白区域。在此先感谢。

这是代码

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

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:requiresFadingEdge="vertical"
        android:fadingEdgeLength="90dp"
        android:fadingEdge="vertical"
        android:fillViewport="true"
        >

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

            <ImageView
                android:id="@+id/image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minHeight="275dp"
                android:scaleType="center"
                android:src="@drawable/bubble_exclaimation"
                app:layout_constraintBottom_toTopOf="@id/content_layout"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <android.support.constraint.ConstraintLayout
                android:id="@+id/content_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/image"
                android:background="@android:color/holo_blue_dark"
                android:paddingBottom="15dp"
                >

                <TextView
                    android:id="@+id/title"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="@string/title"
                    android:textSize="17sp"
                    app:layout_constraintBottom_toTopOf="@+id/body"
                    app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                    app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                    app:layout_constraintTop_toBottomOf="parent" />

                <TextView
                    android:id="@+id/body"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="13dp"
                    android:text="@string/content_small"
                    android:textSize="12sp"
                    app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                    app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                    app:layout_constraintTop_toBottomOf="@+id/title" />

                <android.support.constraint.Guideline
                    android:id="@+id/left_guideline"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_percent="0.11" />

                <android.support.constraint.Guideline
                    android:id="@+id/right_guideline"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_percent="0.89" />
            </android.support.constraint.ConstraintLayout>

        </android.support.constraint.ConstraintLayout>


    </ScrollView>

    <View
        android:id="@+id/block"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="10dp"
        android:background="@android:color/holo_blue_dark"
        app:layout_constraintTop_toBottomOf="@id/scrollView"
        app:layout_constraintBottom_toBottomOf="parent"
        />

</android.support.constraint.ConstraintLayout>

最佳答案

android:id="@+id/content_layout" 中移除 app:layout_constraintTop_toBottomOf="@+id/image"

 <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fadingEdge="vertical"
            android:fadingEdgeLength="90dp"
            android:fillViewport="true"
            android:requiresFadingEdge="vertical">

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

                <ImageView
                    android:id="@+id/image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:minHeight="275dp"
                    android:scaleType="center"
                    android:src="@drawable/bubble_exclaimation"
                    app:layout_constraintBottom_toTopOf="@id/content_layout"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <android.support.constraint.ConstraintLayout
                    android:id="@+id/content_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/holo_blue_dark"
                    android:paddingBottom="15dp"
                    app:layout_constraintBottom_toBottomOf="parent">

                    <TextView
                        android:id="@+id/title"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:text="@string/title"
                        android:textSize="17sp"
                        app:layout_constraintBottom_toTopOf="@+id/body"
                        app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                        app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                        app:layout_constraintTop_toBottomOf="parent" />

                    <TextView
                        android:id="@+id/body"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="13dp"
                        android:text="@string/content_small"
                        android:textSize="12sp"
                        app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                        app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                        app:layout_constraintTop_toBottomOf="@+id/title" />

                    <android.support.constraint.Guideline
                        android:id="@+id/left_guideline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="0.11" />

                    <android.support.constraint.Guideline
                        android:id="@+id/right_guideline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="0.89" />
                </android.support.constraint.ConstraintLayout>

            </android.support.constraint.ConstraintLayout>


        </ScrollView>

        <View
            android:id="@+id/block"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="10dp"
            android:background="@android:color/holo_blue_dark"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="@id/scrollView" />


    </android.support.constraint.ConstraintLayout>

关于android - 约束布局在底部有额外的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50146511/

有关android - 约束布局在底部有额外的空间的更多相关文章

  1. ruby - nanoc 和多种布局 - 2

    是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'

  2. ruby-on-rails - 从应用程序中自定义文件夹内的命名空间自动加载 - 2

    我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty

  3. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  4. ruby-on-rails - Ruby 中意外的大小写行为 - 2

    我在一段非常简单的代码(如我所想)中得到了一个错误的值:org=4caseorgwhenorg=4val='H'endputsval=>nil请不要生气,我希望我错过了一些非常明显的东西,但我真的想不通。谢谢。 最佳答案 这是典型的Ruby错误。case有两种被调用的方法,一种是你传递一个东西作为分支的基础,另一种是你不传递的东西。如果您确实在case中指定了一个表达式语句然后评估所有其他条件并与===进行比较.在这种情况下org评估为false和org===false显然不是真的。所有其他情况也是如此,它们要么是真的,要么是假的。

  5. ruby - 在 Ruby 中跳过额外的关键字参数 - 2

    我定义了一个方法:defmethod(one:1,two:2)[one,two]end当我这样调用它时:methodone:'one',three:'three'我得到:ArgumentError:unknownkeyword:three我不想从散列中一个一个地提取所需的键或排除额外的键。除了像这样定义方法之外,有没有办法规避这种行为:defmethod(one:1,two:2,**other)[one,two,other]end 最佳答案 如果不想写**other中的other,可以省略。defmethod(one:1,two:2

  6. ruby-on-rails - 如何添加具有额外列的多对多记录 - 2

    我有以下模型用户has_many:users_contactshas_many:contacts,through::users_contactsaccepts_nested_attributes_for:contacts,allow_destroy:true联系方式has_many:users_contactshas_many:users,through::users_contactsaccepts_nested_attributes_for:users_contacts,allow_destroy:true用户联系belongs_to:usersbelongs_to:contacts

  7. ruby-on-rails - 带有自定义 rails 表单生成器的额外字段 - 2

    我有一个自定义表单生成器,使用此自定义生成器的原因之一是对于每个表单,我都需要包含一些额外的参数,我不想在每个表单中使用隐藏字段标签显式放入这些参数写。for_for(@foo,:builder=>MyBuilder)do|f|#stuffIshouldn'thavetoworryabout#thisshouldbeputinallthetimewithoutmehavingtodoithidden_field_tag('extra','myextrainfo')#normalthingsIwouldputinf.text_field(:bar)end我必须在我的自定义表单构建器中做什

  8. ruby 认为我在引用一个顶级常量,即使我指定了完整的命名空间 - 2

    在我的应用程序中我有classUserincludeUser::FooendUser::Foo定义在app/models/user/foo.rb现在我正在使用一个定义了自己的Foo类的库。我收到此错误:warning:toplevelconstantFooreferencedbyUser::FooUser仅引用具有完整路径的Foo,User::Foo,而Foo实际上从来没有指的是Foo。这是怎么回事?更新:才想起我之前遇到过同样的问题,在问题1中看到这里:HowdoIrefertoasubmodule's"fullpath"inruby? 最佳答案

  9. Ruby 命名空间与类还是模块? - 2

    考虑Ruby类Foo::Bar。惯例是将“Foo”命名空间作为一个模块,但它也可以很容易地作为一个类:moduleFoo;classBar;end;end对比:classFoo;classBar;end;end在第二种情况下,Bar不是Foo的内部类,它只是在Foo的单例上定义的另一个常量。在这两种情况下,父类(superclass)都是Object并且它们只包含Kernel模块。它们的祖先链是相同的。因此,除了您可以根据其类使用Foo进行的操作(如果是类则实例化,如果是模块则扩展/包含),命名空间的性质是否对有任何影响酒吧?是否有令人信服的理由选择其中一个名称间距而不是另一个?我看到

  10. ruby - 如何在命名空间类中包含模块? - 2

    我在将模块包含在命名空间类中时遇到问题。下面的示例抛出错误uninitializedconstantBar::Foo::Baz(NameError)。我在这里缺少哪些基本的Ruby知识?moduleFoomoduleBazdefhelloputs'hello'endendendmoduleBarclassFooincludeFoo::Bazendendfoo=Bar::Foo.new 最佳答案 使用::强制查找到顶层:moduleBarclassFooinclude::Foo::Bazendend

随机推荐