Pergunta

just wanted to make a clickable image and I don't know which option will be more efficient. What's better: a button that has a background image or a imageview that is clickable?

Foi útil?

Solução

Adding clickListener to ImageView is a cleaner way. In the button, you may face issues like, image not being bordered properly. It can be done with changes in xml, but its an overhead.

ImageView imageView = (ImageView) findViewById(R.id.<ImageViewId>);
imageView.setOnClickListener(this);

In the onClick(View view) method, handle the click event.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top