【问题标题】:Removing padding and margins from Android RelativeLayout从 Android RelativeLayout 中删除填充和边距
【发布时间】:2020-05-06 09:44:52
【问题描述】:

Spaces between generated layouts

我已经尝试了所有方法,但不知道如何删除每个块之间的空格。它们是由用户输入生成的集合,因此代码用于模板

<LinearLayout
    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:textAlignment="center"
    android:gravity="center_horizontal"
    android:weightSum="100"
    android:layout_margin="0dp"
    android:paddingBottom="0dp"
    android:paddingTop="0dp"
    android:layout_marginBottom="-20dp"
    android:divider="@null"
    android:dividerHeight="0dp"
    xmlns:xmls="http://schemas.android.com/apk/res-auto">

【问题讨论】:

  • 我只在 sn-p 中看到 LinearLayout。可以分享一下容器视图代码吗?

标签: java android xml layout formatting


【解决方案1】:

最好的解决方案是,如果您将 recyclerview 与适配器一起使用。这是一个相当不错的tutorial。显然,在相对布局部分,您需要使用包装内容并匹配父项。

【讨论】: