I have an example running like this:
<Switch
android:id="@+id/sw_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:enabled="@{!swAuto.checked}"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Zustand"
android:textColor="@{swAuto.checked ? @color/outlet_preview_card_text_disabled : @color/outlet_preview_card_text}"
android:textSize="14sp"
tools:textColor="@color/outlet_preview_card_text"/>
But I need to set the alpha in another view depending on another's view visibility like:
<LinearLayout
android:id="@+id/ll_global_outlet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/round_background_white"
android:orientation="vertical"
android:alpha="@{ivProgressBar.visibility == View.VISIBLE ? 0.90 : 1}"
android:padding="10dp">
But I am getting this error:
Error:(45, 30) Could not resolve the two-way binding attribute 'visibility' on type 'android.widget.ImageView'
Any idea what I am doing wrong?
this is the view I should depend on:
<ImageView
android:id="@+id/iv_progress_bar"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:visibility="gone"
tools:visibility="visible"
android:background="@drawable/progress_bar_animation"/>
In case someone wonders I couldn't do it that way.
I decided that when my VM calls startProgressBar() this method will update my model having a field called isUpdating which will be Bindable and my VM extends Observable so with this:
android:alpha="@{shDevice.isUpdating ? 0.3f : 1.0f}"
would do what I want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With