[android] ConstraintLayout에서의 가시성 및 투명도 설정

가시성을 설정하려면 Visibility 속성을 사용하고, 투명도를 조절하려면 Alpha 속성을 사용해야 합니다.

1. 뷰의 가시성 설정하기

가시성을 변경하려면 XML 파일에서 뷰의 Visibility 속성 값을 변경하면 됩니다. 가시성은 다음과 같이 3가지 옵션으로 설정할 수 있습니다.

<ImageView
    android:id="@+id/myImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/my_image"
    android:visibility="invisible" />

위의 예제에서 android:visibility="invisible"를 통해 해당 이미지가 처음에는 보이지 않도록 설정되었습니다.

2. 뷰의 투명도 조절하기

뷰의 투명도는 Alpha 속성을 사용하여 조절할 수 있습니다. Alpha 값은 0.0에서 1.0 사이의 부동 소수점으로 표시하며, 0.0은 완전 투명하고, 1.0은 완전 불투명을 나타냅니다.

<ImageView
    android:id="@+id/myImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/my_image"
    android:alpha="0.5" />

위의 예제에서 android:alpha="0.5"를 통해 해당 이미지가 반투명으로 설정되었습니다.

이렇게하여 ConstraintLayout에서 뷰의 가시성과 투명도를 설정할 수 있습니다.

참고: Android Developer - View 가시성 관리하기