ImageView imageView = findViewById(R.id.imageView); imageView.setAlpha(0.5f); // sets the opacity of the ImageView to 50%
TextView textView = findViewById(R.id.textView); Button button = findViewById(R.id.button); textView.setAlpha(1.0f); // sets the opacity of the TextView to 100% button.setAlpha(0.2f); // sets the opacity of the Button to 20%The setAlpha() method is a part of the `android.view.View` class, which is included in the Android SDK.