Android databinding: set default visibility in xml

前端 未结 2 1620
独厮守ぢ
独厮守ぢ 2021-02-13 03:17

I show items in recyclerview and use databinding. In xml layout I has such view:

 

        
相关标签:
2条回答
  • 2021-02-13 03:39

    Check if you have already imported the View class.

    <data>
        <import type="android.view.View"/>
        <variable ..... />
    </data>
    

    Also, the default correct syntax for default value for visibility is default=gone, no default=View.GONE

    0 讨论(0)
  • 2021-02-13 03:42

    You can set gone, visible, invisible in default property. Replace with below.

    <include
            android:visibility="@{viewmodel.expandable ? View.VISIBLE : View.GONE, default=gone}"
            bind:viewmodel="@{viewmodel}"
            layout="@layout/full_station_layout"/>
    
    0 讨论(0)
提交回复
热议问题