Android Question (Solved) Button movement before clicking

f0raster0

Well-Known Member
Licensed User
Longtime User
Hello team,

I currently have a small application running on Android TV, and I am using the remote control to select and click a button as illustrated in the picture below.

What settings do I need to add to enable the visualization of button movement before clicking?
Currently, when I click a button, I see it in red. However, I am looking to change the color before clicking. What settings do I need to modify to achieve this?

A1.jpg


Thank you in advance!
 
Solution
I was a little wrong. Css is for B4J.
You must use StateListDrawable

Example:
B4A:
Sub FormatButtons(P as Panel) 'P = The panel with the buttons

    Dim Focused, NotFocused As ColorDrawable
    Focused.Initialize(Colors.Blue, 0dip)
    NotFocused.Initialize(Colors.RGB(100,100,100),0)
 
    For Each v As View In P
   
         If v is Button then
            Dim sld As StateListDrawable
            sld.Initialize
            sld.AddState(sld.State_Focused, Focused)
            sld.AddState(sld.State_Enabled, NotFocused)

            v.Background = sld
       
        End If
   
    Next

zed

Active Member
Licensed User
Have you tried with CSS

CSS:
.button{
    -fx-focus-color: #A0A0A0;
    -fx-faint-focus-color: Transparent;
    -fx-border-width: 0.2;
}
.button:hover{
    -fx-focus-color: #FF0000;
    -fx-faint-focus-color: Transparent;
    -fx-border-width: 0.2;
}
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
I see, it looks like I don't have any idea how to use CSS o_O
 
Upvote 0

zed

Active Member
Licensed User
I was a little wrong. Css is for B4J.
You must use StateListDrawable

Example:
B4A:
Sub FormatButtons(P as Panel) 'P = The panel with the buttons

    Dim Focused, NotFocused As ColorDrawable
    Focused.Initialize(Colors.Blue, 0dip)
    NotFocused.Initialize(Colors.RGB(100,100,100),0)
 
    For Each v As View In P
   
         If v is Button then
            Dim sld As StateListDrawable
            sld.Initialize
            sld.AddState(sld.State_Focused, Focused)
            sld.AddState(sld.State_Enabled, NotFocused)

            v.Background = sld
       
        End If
   
    Next
 
Last edited:
Upvote 0
Solution

Cableguy

Expert
Licensed User
Longtime User
Look for the hooks librarie. It will enable you to add the entered/exited events for a particular view
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Found this one

Hooks is also for b4j, my bad
 
Upvote 0
Top