XML : Add dimen resource to layout using Android Binding Library

I'm using Android's binding library and I'm trying to add or remove the margin on a TextView depending on the value of a boolean. If it's true, I want the TextView to have a margin on the right and no margin on the left and if not then the opposite. All the other resources work fine but when I compile the code I get this error about the margins on the TextView: Cannot find the setter for attribute 'android:layout_marginRight' with parameter type float.

Can anyone spot the error?

This is my xml:

  <?xml version="1.0" encoding="utf-8"?>  <layout xmlns:android="http://schemas.android.com/apk/res/android">      <data>          <variable name="comment" type="mx.com.corpogas.dataModels.FeedbackComment"/>          <import type="android.view.View"/>      </data>            <TextView              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:background="@{comment.isMine ? @drawable/comment_background_white : @drawable/comment_background_green}"              android:textSize="15sp"              android:textColor="@{comment.isSent ? (comment.isMine ? @color/colorPrimaryDark : @android:color/white) : @color/unsent_text}"              android:layout_marginRight="@{comment.isMine ? @dimen/feedback_comment_margin : @dimen/feedback_comment_no_margin}"              android:layout_marginLeft="@{comment.isMine ? @dimen/feedback_comment_no_margin : @dimen/feedback_comment_margin}"              android:text="@{comment.content}"/>      </layout>    

And this are my margins:

  <dimen name="feedback_comment_margin">16dp</dimen>  <dimen name="feedback_comment_no_margin">0dp</dimen>    

When I remove the margins the program compiles and runs perfectly.

No comments:

Post a Comment