2
我正在使用Android的綁定庫,我試圖根據布爾值添加或刪除邊距。如果這是真的,我希望TextView在右邊有一個邊距,在左邊沒有邊距,如果不是則相反。所有其他資源工作正常,但是當我編譯代碼時,我得到了關於TextView邊距的這個錯誤:無法找到參數類型爲float的屬性'android:layout_marginRight'的setter。使用Android綁定庫添加維度資源到佈局
任何人都可以發現錯誤?
這是我的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>
這是我的利潤:
<dimen name="feedback_comment_margin">16dp</dimen>
<dimen name="feedback_comment_no_margin">0dp</dimen>
當我刪除的程序編譯和運行完美的利潤率。
同樣的問題,答案http://stackoverflow.com/questions/34832578/android-databinding-how-to-get-dimensions-from-dimens -xml! –