小编sha*_*bia的帖子

使用数据绑定后查看边距不起作用

下面是gridview的item布局的代码。在此, layout_margin 在设计面板中,但是当我运行时没有边距。我试图检查其他标签,如背景,发现它正在工作。一个类似的问题是 linear_layout 的 layout_weights,它们也不起作用。这些在没有数据绑定的情况下工作正常。有人可以帮我解决这个问题吗?'''

<?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">

    <data>

        <variable
            name="localEntry"
            type="com.example.lo_cal.data.models.LoCalEntry" />
    </data>

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/small"
        android:background="@color/colorAccent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/item_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:itemId="@{localEntry}"
            tools:text="ID" />

        <TextView
            android:id="@+id/item_first_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@{localEntry.firstName}"
            tools:text="shashank" />

        <TextView
            android:id="@+id/item_second_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@{localEntry.secondName}"
            tools:text="mohabia" />

        <TextView
            android:id="@+id/item_result"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@{localEntry.result}"
            tools:text="100" />
    </androidx.appcompat.widget.LinearLayoutCompat>
</layout>
Run Code Online (Sandbox Code Playgroud)

'''

data-binding android kotlin android-viewholder android-recyclerview

6
推荐指数
1
解决办法
521
查看次数