ImageView that can be selected

1

I have this ImageView And I want that when you click on it, of the sensation of a button, as well as that it changes color.

<ImageView
    android:id="@+id/image_view"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:src="@drawable/ic_image" />
    
asked by Doble-L 19.10.2018 в 16:07
source

1 answer

-1

You can use setOnClickListener as a button to click on ImageView and make an action, in this case change the background color as you request.

  ImageView imageview=(ImageView)findViewById(R.id.image_view);
  imageview.setOnClickListener(new OnClickListener(){

   @Override
     public void onClick(View v) {
                 //cambiar el color de background de dicha imagen al clicarla
                 imageView.setBackgroundColor(Color.rgb(100, 100, 50));
               }
     });
    
answered by 19.10.2018 в 18:23