相关疑难解决方法(0)

Android 中是否可以删除子填充

我有一个线性布局。在家长看来,我已经定义了填充。但我想从子视图中删除填充。是否可以删除中间子视图填充?我知道一种解决方案是我需要单独提供填充。但我不想使用这个解决方案。所以任何替代解决方案。

布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tool="http://schemas.android.com/tools"
    android:padding="16dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:visibility="gone"
        tool:text="Header text" />

    <View
        android:id="@+id/separator"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:layout_marginTop="10dp"
        android:background="#cccccc"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@id/header" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/dialog_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dp" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

上面的代码看起来像这样

在此输入图像描述

预期输出

在此输入图像描述

android android-layout android-linearlayout android-constraintlayout

4
推荐指数
1
解决办法
1000
查看次数