There is such code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:background="@drawable/bacground" android:theme="@style/AppTheme.NoActionBar" android:layout_margin="2dp" android:gravity="center" tools:context=".fragment3"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/b1" android:scaleType="centerInside" android:src="@drawable/a" android:clickable="true" android:layout_gravity="center"/> </LinearLayout> 

Handler

 switch (v.getId()) { case R.id.b1: startActivity(getActivity(), a1.class); //тут я вызываю новое активти и фон android:background="@drawable/bacground" должен затемняться break; ... } 

enter image description here

    1 answer 1

    Set the background color with alpha channel. Alfakanal - the first two letters, it adjusts the transparency. Example:

     background="#DD000000" 
    • So, if I already have a background in my picture, I need to darken it by pressing the element, here's what to do - upward