Android XML 截断布局的下半部分

2023-12-26

我的 XML 布局有问题,我认为这不会给我带来很多问题。我在滚动视图中有一个布局,但是布局的底部被切断,我看不到第二个列表视图之后的任何内容。环顾四周,我似乎看不出 xml 本身有什么问题,也看不出我做错了什么。

我已经尝试过针对该问题的建议,即为每个不同元素添加权重,但这仍然没有解决问题。

我还添加了放置片段的主要活动,以防可能有助于解决问题

XML 片段

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
android:id="@+id/coordinatorLayout">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbars="vertical">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <android.support.design.widget.TextInputLayout
            android:id="@+id/text_input_layout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <EditText
                android:id="@+id/editText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Recipe Title"/>
        </android.support.design.widget.TextInputLayout>

        <TextView
            android:id="@+id/ingredientsHeading"
            android:layout_below="@+id/text_input_layout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:text="Ingredients"
            android:textStyle="bold|italic"
            android:layout_weight="1" />
        <ListView
            android:id="@+id/ingredientsList"
            android:layout_below="@+id/ingredientsHeading"
            android:layout_above="@+id/directionsHeading"
            android:layout_width="wrap_content"
            android:layout_height="195dp"
            android:layout_weight="1"></ListView>

        <Button style="@style/Button"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:text="Add Ingredient"
            android:id="@+id/addIngredient"
            android:layout_below="@+id/ingredientsList"
            android:enabled="true"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1" />

        <TextView
            android:id="@+id/directionsHeading"
            android:layout_below="@+id/addIngredient"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:text="Directions"
            android:textStyle="bold|italic"
            android:layout_weight="1" />
        <ListView
            android:id="@+id/directionsList"
            android:layout_below="@+id/directionsHeading"
            android:layout_width="wrap_content"
            android:layout_height="195dp"
            android:layout_weight="1"></ListView>

        <Button style="@style/Button"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:text="Add Direction"
            android:id="@+id/addDirection"
            android:layout_below="@+id/ingredientsList"
            android:enabled="true"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1" />

    </LinearLayout>

</ScrollView>


<android.support.design.widget.FloatingActionButton
    android:id="@+id/filterButton"
    app:backgroundTint="@color/floatingButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:clickable="true"
    android:src="@drawable/ic_filter"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="63dp"
    android:layout_marginRight="16dp" />


</android.support.design.widget.CoordinatorLayout>

Main XML

<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout2">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <FrameLayout
        android:id="@+id/container_body"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</android.support.design.widget.CoordinatorLayout>


<fragment
    android:id="@+id/fragment_navigation_drawer"
    android:name="com.example.rory.pocketchef.Fragments.FragmentDrawer"
    android:layout_width="@dimen/nav_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:layout="@layout/fragment_navigation_drawer"
    tools:layout="@layout/fragment_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>

我解决了这个问题。当显示滚动视图时,底部被实际手机上的底部操作栏切断。因此,为了解决这个问题,我在滚动视图的底部添加了填充,以便将其推回到操作栏上方。

新的布局如下

更新了工作 XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
android:id="@+id/coordinatorLayout">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbars="vertical"
    android:paddingBottom="?android:attr/actionBarSize"> <<<-------added this line
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <android.support.design.widget.TextInputLayout
            android:id="@+id/text_input_layout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <EditText
                android:id="@+id/editText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Recipe Title"/>
        </android.support.design.widget.TextInputLayout>

        <TextView
            android:id="@+id/ingredientsHeading"
            android:layout_below="@+id/text_input_layout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:text="Ingredients"
            android:textStyle="bold|italic"
            android:layout_weight="1" />
        <ListView
            android:id="@+id/ingredientsList"
            android:layout_below="@+id/ingredientsHeading"
            android:layout_above="@+id/directionsHeading"
            android:layout_width="wrap_content"
            android:layout_height="195dp"
            android:layout_weight="1"></ListView>

        <Button style="@style/Button"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:text="Add Ingredient"
            android:id="@+id/addIngredient"
            android:layout_below="@+id/ingredientsList"
            android:enabled="true"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1" />

        <TextView
            android:id="@+id/directionsHeading"
            android:layout_below="@+id/addIngredient"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:text="Directions"
            android:textStyle="bold|italic"
            android:layout_weight="1" />
        <ListView
            android:id="@+id/directionsList"
            android:layout_below="@+id/directionsHeading"
            android:layout_width="wrap_content"
            android:layout_height="195dp"
            android:layout_weight="1"></ListView>

        <Button style="@style/Button"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:text="Add Direction"
            android:id="@+id/addDirection"
            android:layout_below="@+id/ingredientsList"
            android:enabled="true"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_below="@+id/addDirection">

            <Button style="@style/Button"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:text="Add Direction"
                android:id="@+id/showOptionsDialog"
                android:enabled="true"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1" />

            <Button style="@style/Button"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:text="Add Direction"
                android:id="@+id/saveRecipe"
                android:enabled="true"
                android:layout_gravity="center_horizontal"
                android:layout_toRightOf="@+id/showOptionsDialog"
                android:layout_weight="1" />


        </RelativeLayout>

    </LinearLayout>

</ScrollView>


<android.support.design.widget.FloatingActionButton
    android:id="@+id/filterButton"
    app:backgroundTint="@color/floatingButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:clickable="true"
    android:src="@drawable/ic_filter"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="63dp"
    android:layout_marginRight="16dp" />


</android.support.design.widget.CoordinatorLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android XML 截断布局的下半部分 的相关文章

随机推荐

  • 如何将 numpy 数组呈现到 pygame 表面?

    我正在编写一段代码 其中一部分是读取图像源并将其显示在屏幕上以供用户交互 我还需要锐化的图像数据 我使用以下方法读取数据并将其显示在pyGame def image and sharpen array file name read the
  • 如何让 XSL 中的 javascript for 循环中的 less 起作用?

    我正在使用 CDATA 来转义脚本 但在 IE8 的调试器中 我仍然收到此消息 在 for 循环条件中 预期 我假设它仍然认为 在里面 lt CDATA 生成的是结束循环条件 我的 XSL 模板中的原始脚本
  • 通过 Terraform 创建 Azure Windows VM

    在 Azure 中 我尝试使用 Terraform 创建 Windows VM 我之前已经使用 Template json 文件通过 Powershell 完成了此操作 现在我要处理 terraform 我对它完全陌生 所以我搜索了一些在A
  • 是否可以使用 php 或 javascript 获取硬件信息?

    是否可以使用 php 脚本获取硬件详细信息 是否可以通过 php 脚本检查笔式驱动器或其他设备是否连接到电脑 因此 当用户加载网页时 它应该显示 Pendrive 已连接到您的计算机 是否可以 请参阅此链接 它是如何工作的 http lin
  • 创建 Excel SUMIF 函数的 R 版本,可用于测量连续在多个数据集上运行的模型的性能

    首先 这个问题是一个后续问题最近的问题 https stackoverflow com questions 74956321 creating the equivalent of a sumif function in excel 7495
  • 如何为 JSON 主体创建自定义绑定器?

    我正在使用 play 框架 我想为来自 POST 方法的 JSON 创建一个自定义绑定器 我试图用 Global TypeBinder 来做到这一点 但这似乎只适用于形式编码的情况 我正在挖掘 Binder java 它似乎没有考虑用于绑定
  • 在 Tesseract 中识别数字时遇到问题 - android

    我希望有人能告诉我为什么我的 Tesseract 无法识别一些带有数字的图像 以及我是否可以对此做些什么 一切都根据测试工作 并且由于它只是我需要的数字 我认为我可以使用英文模式进行管理 直到我也必须从 7 段显示开始 虽然我在附加图像方面
  • INSERT ON CONFLICT DO NOTHING 和 SELECT 之间的竞争条件

    Does a SELECT查询以下INSERT ON CONFLICT DO NOTHING给定默认事务隔离 读已提交 的情况下 语句总是找到一行 我想要INSERT or SELECT一个表中的一行 然后在第二个表中插入行时引用该行 自从
  • 使用glide库进行图像灰度化

    我正在使用 glide 库在图像视图中加载图像 url Glide with context load imageurl apply RequestOptions circleCropTransform into holder thumbn
  • Mysqli 准备语句破坏了图像插入数据库

    我有一个 sql 语句工作正常 直到我尝试将其更改为 sql 准备好的语句 这是旧的插入 sql INSERT INTO items seller post date expiration date image description na
  • Bootstrap 下拉菜单:删除滚动条

    我正在以下工作GitHub Repo https github com patreu22 Twittex 当窗口宽度减小时 导航栏会折叠并更改为带有滚动条 宽度和高度 的下拉菜单 我怎样才能删除这些滚动条 我尝试添加 navbar coll
  • $Proxy25 无法转换为我的类 Spring 框架

    我在运行测试时遇到此异常 我正在尝试在 spring 中配置 aop java lang ClassCastException Proxy25 cannot be cast to path UserDao at com playence a
  • 如何通过包含另一个按钮的宽度加上常量来编写 NSConstraint 视觉格式语言

    In the docs https developer apple com library ios documentation UserExperience Conceptual AutolayoutPG VisualFormatLangu
  • 查找 3D 中 X、Y 和 Z 轴的角度 - OpenGL/C++

    我目前正在尝试使用OpenGL 使用SDL 将一个立方体绘制到我在屏幕上单击鼠标左键的位置 然后让它指向我在屏幕上单击鼠标右键的位置 我可以使用 gluUnproject 在我想要的位置成功绘制一个立方体 这意味着我已经知道我的立方体所在的
  • 使用 JSON POST 请求

    我正在尝试使用 JSON 向 API 发起 POST 请求 我找到了一些示例代码 在我深入之前我想让它工作 但我被困住了
  • 部分模板的 C++ typedef

    我需要做这样的 typedef template lt class A class B class C gt class X template lt class B class C gt typedef X lt std vector b
  • Android SDK 工具旧版本(带有可用的 android 工具)

    我尝试从官方网站安装 android SDK 它包括最新的android SDK工具 版本25 3 1 这个包有实用性android我的项目需要它 非常大的一个 但这个工具不再可用 android 命令不再可用 对于手动 SDK 和 AVD
  • 我可以在 Objective-C 接口中声明“协议”类型的变量吗?

    我的想法与java中声明接口类型的变量非常相似 例如 头文件1 protocol Calculator end 然后我定义一个 interface CalculatorImpl它实现了上面的Calculator协议 在头文件2中 inter
  • 泡菜替代品

    我正在尝试序列化一个大的 10 6行 每行 20个值 列表 以便稍后由我自己使用 因此pickle缺乏安全性不是问题 列表的每一行都是一个值元组 源自某个 SQL 数据库 到目前为止 我已经看到了datetime datetime 字符串
  • Android XML 截断布局的下半部分

    我的 XML 布局有问题 我认为这不会给我带来很多问题 我在滚动视图中有一个布局 但是布局的底部被切断 我看不到第二个列表视图之后的任何内容 环顾四周 我似乎看不出 xml 本身有什么问题 也看不出我做错了什么 我已经尝试过针对该问题的建议