The app sample I gave you covers and DOES exactly what you want.
However, is not as simple as copy/paste my code into your app. Based on what you described, the trick is in the sections:
Public Sub CreateButtonColor(FocusedColor As Int, EnabledColor As Int, DisabledColor As Int, PressedColor As Int) As StateListDrawable
and
Sub Buttondraw(btn As Button,btntxt As String,fns As Int,cl As Int)
of the code I gave you in the "MyApp."
Here are the codes of those sections, which are found in the "Main Activity Window":
This is for DRAWALBES
Public Sub CreateButtonColor(FocusedColor As Int, EnabledColor As Int, DisabledColor As Int, PressedColor As Int) As StateListDrawable
Dim res As StateListDrawable
res.Initialize
Dim drwFocusedColor, drwEnabledColor, drwDisabledColor, drwPressedColor As ColorDrawable
drwFocusedColor.Initialize2(FocusedColor, 0, 1, Colors.White)
drwEnabledColor.Initialize2(EnabledColor, 0, 0, Colors.RGB(110,110,110))
drwDisabledColor.Initialize2(DisabledColor, 0, 0, Colors.RGB(110,110,110))
drwPressedColor.Initialize2(PressedColor, 0, 0, Colors.RGB(110,110,110))
res.AddState(res.State_Focused, drwFocusedColor)
res.AddState(res.State_Pressed, drwPressedColor)
res.AddState(res.State_Enabled, drwEnabledColor)
res.AddState(res.State_Disabled, drwDisabledColor)
res.AddCatchAllState(drwEnabledColor)
Return res
End Sub
and...
THIS IS FOR IMAGES
Sub Buttondraw(btn As Button,btntxt As String,fns As Int,cl As Int)
Dim bx,by As Int
Dim bdwFocused As BitmapDrawable
Dim bdwEnabled As BitmapDrawable
Dim bdwPressed As BitmapDrawable
Dim bdwDisabled As BitmapDrawable
buttonlabel.Text=btntxt
buttonlabel.TextSize=fns
Dim Height_, Width_ As Int
buttonlabel.Width = -2
buttonlabel.Height = -2
DoEvents
obj.Target = buttonlabel
Width_ = obj.RunMethod("getWidth")
Height_ = obj.RunMethod("getHeight")
buttonpic.Width=btn.Width
buttonpic.Height=btn.Height
c.Initialize(buttonpic)
bx=(btn.Width-Width_)/2
by=(btn.Height+fns)/2
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwEnabled.Initialize(buttonpic.Bitmap)
Dim Focused As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Copper_Brown_Brushed_07_Focused.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwFocused.Initialize(buttonpic.Bitmap)
bdwEnabled.Initialize(buttonpic.Bitmap)
Dim bdwEnabled As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Copper_Brown_Brushed_01_Enabled.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwEnabled.Initialize(buttonpic.Bitmap)
Dim bdwPressed As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Steel_LightBlue_Brushed_01_Pressed.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwPressed.Initialize(buttonpic.Bitmap)
Dim bdwDisabled As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Steel_Brushed_08_Disabled.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, Colors.Gray, "LEFT")
bdwDisabled.Initialize(buttonpic.Bitmap)
Dim stdBitmap As StateListDrawable
stdBitmap.Initialize
Dim states(4) As Int
states(0) = stdBitmap.state_Focused
states(1) = stdBitmap.state_Enabled
states(2) = -stdBitmap.state_Pressed
states(3) = -stdBitmap.state_Disabled
stdBitmap.addState2(states, bdwFocused)
Dim states(2) As Int
states(0) = stdBitmap.state_Enabled
states(1) = -stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwEnabled)
Dim states(1) As Int
states(0) = stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwPressed)
btn.background=stdBitmap
End Sub
Take a good look at the bottom of the second code, right where it says:
Dim state(4) As Int You will notice that it calls for four (4) different button states: Focused, Enabled, Pressed, and Disabled. You must provide an image for each state, even though you only need 3, normal, focus, and pressed. If you analyse the code, you will find that I am using 4 images:
1. "Metal_Copper_Brown_Brushed_07_Focused.jpg"
2. "Metal_Copper_Brown_Brushed_01_Enabled.jpg"
3. "Metal_Steel_LightBlue_Brushed_01_Pressed.jpg"
4. "Metal_Steel_Brushed_08_Disabled.jpg"
This one I used for the text on the button, but with or without it works... I simply left it there:
1. "Brushed_Steel_Blue_01.jpg"
The naming of my files is too much maybe, but you can rename your files any way you want, but I suggest to add at the end the "Focused, Enabled, Pressed, and Disabled" to make it easy to understand and locate withing the code.
The real trick is in the last sections of the code:
Dim States(4) as Int,
Dim States(2) As Int, and
Dim States(1) as Int
Just keep it the way I have it and simply replace all of my 4 images with your images and it will work just fine. Your Zebra (for example) will be in 4 versions: one for normal state, one when being focus (which is the same one as the normal state, is just that you either add a border with an image editor or change the intensity of the color and save it as a different image), one for when being pressed (the same as the original normal image, but you must edit the photo and make the colors very bright to show that it is being focus - or something to that effect) and save that image as a new file, and maybe a gray zebra for the disabled state even though it might not be used at all depending on the requirements of your app. I'm not using it in the app I gave you. BUT it still needs to be there.
I suggest this: use my sample app and inject your "zebra" images in it, and play with the code until you understand what's going on and get the results you are looking for. Install the sample "MyApp" to the TV to make sure it is working fine. Then, bring more of your own code (browsing through images, going to the next level, setting levels of difficulties, etc,) into my sample app and "grow it" a bit at a time until you get it to work like your app, or the way you want your app to work. It is easier to tackle a sample of the problem than to face the whole thing at once... some other part of your code might be conflicting and you won't know until you work a bit of code at a time. The main objective is to show focus on the SmartTV, done... MyApp does that. Now add to that "sections" of your code, a bit at a time... until the main sections are all working fine. Once you achieve that, go and modify your actual app code. That's the easiest way... less troubleshooting.
Also, I forgot to mention earlier that you must use the following libraries (or it will not work):
Accessibility
Core
JavaObject
Phone
Reflection
RippleEffect
The "RippleEffect" library is only needed if you use the part of the code for the... wait for it... wait for it... ripple effect. If you don't want that, remove that code and don't install the library.
BY THE WAY, have you looked at the code I have in the "Manifest":
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:xlargeScreens="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
SetApplicationAttribute(android:banner, "@drawable/banner")
AddActivityText(TvActivity,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>)
As I said, work with the little -that does work- sample app I sent you and analyze the entire code, then, import your own code a section at a time... make one section work, then proceed to the next one... trust me, I do this for a living (not precisely programming, but troubleshoot computer problems of all sorts, including programming).
I'm going to bed now. Ciao.
p.s. Seriously, install the app I gave you onto your TV and make sure it works. I tried it only on Android TVs, not SamSungs or LGs... if it works, now bring your code a bit at a time into my app and grow it... that's the fastest way to find a solution to your dilemma and to understand what's going on. If the app does not work on your TV, well, then I cannot help you since I do not have one of those to try it myself. By the way, I just tried the app in a Sony 4k 55" Android TV and it works flawlessly.
One more time, make 4 distinct images of that Zebra (modify the original in three different ways, each way saved as a different file) with an image editor like Gimp or Adobe Photoshop, etc. That's the final trick (besides the code itself) for showing the image being focused on a SmartTV with the D-Pad, and on regular devices you don't need to show focus since you simply tap, but it can be done too.