Поле просмотра не работает после использования привязки данных - PullRequest
0 голосов
/ 21 марта 2020

Ниже приведен код макета элемента gridview. В этом layout_margin есть на панели дизайна, но когда я запускаю, нет никакого поля. Я попытался проверить другие теги, такие как фон, и обнаружил, что он работает. Аналогичная проблема с layout_weights от linear_layout, они также не работают. Они работали нормально без привязки данных. Может кто-нибудь помочь мне решить эту проблему? '' '

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

' ''

...