2016-06-20 1 views
1

다른 뷰의 가시성에서 데이터 바인딩 알파 설정하려고 :내가 예는 다음과 같이 실행이

<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"/> 

을하지만 다른 사람의 뷰 가시성 등에 따라 다른보기에 알파를 설정해야합니다

<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"> 

는하지만이 오류가 점점 오전 :

오류 : (45, 30) 'android.widget.ImageView'

0 유형에 양방향 바인딩 속성 '가시성'을 확인할 수 없습니다

내가 뭘 잘못하고 있는지 알기! 누군가가 내가 그렇게 할 수 없었다 궁금 경우

<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"/> 
+0

'보기 '클래스를 가져 왔습니까? –

+0

와 같은 클래스를 가져 왔습니다. – RogerParis

+0

왜이 두 가지 다른 가시성 속성을 추가 했습니까 : android : visibility = "gone"및'tools : visibility = "visible" '? – Rehan

답변

1

:

내가에 의존해야 할 전망이다.

나는 나의 VM이 startProgressBar를 호출 할 때()이 메소드는 바인딩이 될 것이다 isUpdating라는 필드를 가진 내 모델을 업데이트 할 것입니다 결정이와 나의 VM은 관찰 가능한 확장 :

android:alpha="@{shDevice.isUpdating ? 0.3f : 1.0f}" 

내가 원하는 것을 할 것