Skip to content Skip to sidebar Skip to footer

Android Databinding - Textview Not Visible Depending On A Boolean Value

I'm trying to make a TextView visible depending on when a boolean's value is set to true and a LinearLayout's visibility depending on the false value of the same boolean variable u

Solution 1:

You can make observable boolean in model class and set true and false as your requirement.

e.g

<TextView
        android:id="@+id/logging_in"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical|center_horizontal"
        android:text="@string/logging_in"
        android:visibility="@{profileViewModel.isLoading ? View.GONE : View.VISIBLE}"/>

Post a Comment for "Android Databinding - Textview Not Visible Depending On A Boolean Value"