Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button color change on hover

I'm just a beginner with Android. I want the button to change its color on mouseover.
I don't know how to do that in android. Can it be done?

View for a button:

<Button 
  android:id="@+id/b8"
  android:text="click me"
  style="?android:attr/buttonStyleSmall"
  android:textSize="20dp" />
like image 545
Feona Avatar asked May 10 '12 21:05

Feona


People also ask

How do you change the color of button on hovering?

To change the background color of the button, use the CSS background-color property and give it a value of a color of your taste. In the . button selector, you use background-color:#0a0a23; to change the background color of the button.

How do you change the color of a button in HTML?

Type background-color: in the quotation marks after "style=". This element is used to change the background color of the button. Type a color name or hexadecimal code after "background-color:". You can type name of a color (i.e, blue) or a hexadecimal color.

How do I hover a button in HTML?

The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.


2 Answers

You need to use what's called a selector.

You can read about them and get a tutorial from this site.

Keep in mind that there really isn't a concept in Android as "hover" since you can't hover your finger over the display. But you can create selectors for, say, when a button has focus. Normally a button can have three states: Normal, Focused and Pressed.

like image 65
Icemanind Avatar answered Sep 25 '22 00:09

Icemanind


The particular mouse hover functionality as we know it, is supported on Android OS 4.0 and above. Views have onHoverListeners(). Isnt it finally great

like image 27
samreen Avatar answered Sep 24 '22 00:09

samreen