I'm developing an app can visible Direction pad on the screen, but I don't know how to handle or override action like UP, DOWN, LEFT, RIGHT to focus the next view (like some buttons in image below).
Asked
Active
Viewed 107 times
0
-
Please provide enough code so others can better understand or reproduce the problem. – Community Sep 02 '21 at 08:54
2 Answers
0
Set this tow attributes for your view items :
- android:focusableInTouchMode="true"
- android:background="@drawable/bg_view"
where bg_view.xml is :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape android:shape="rectangle">
<stroke android:width="2dp" android:color="@android:color/white" />
<solid android:color="#1F1F3E" />
</shape>
</item>
<item>
<shape>
<solid android:color="#1F1F3E" />
</shape>
</item>

Hossein
- 439
- 3
- 9
0
I found a solution to what I need here Android simulate key press . Use Instrumentation class to sendKeyEvent.

Phạm Thanh
- 1
- 1
- 2