android - How do I avoid focus highlighting in touch mode? -


i'm trying make app friendly keyboard driven navigation , i've added focus highlight around actionable items. i'm having trouble removing focus highlighting when operating in touch mode. in other words, don't want focus highlighting visible when not using keyboard navigation. possible? i'm experimenting several variations of item states in selector xml toying different values of focusableintouchmode i'm not getting anywhere. have edittext defined follows:

<edittext     android:id="@+id/edittext1"     android:background="@drawable/edit_text_selector"     android:focusable="true"     android:enabled="true"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_aligntop="@+id/textview2"     android:layout_torightof="@+id/textview2"     android:ems="10"     android:inputtype="textemailaddress" >      <requestfocus /> </edittext> 

and have selctor defined here (with many of state permutations commented out):

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">         <item android:state_focused="true">         <layer-list>             <item android:drawable="@drawable/focusbox"/>             <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">                 <corners android:radius="8dp" />                 <stroke android:width="1dp" android:color="#044401" />                 <solid android:color="@color/edit_text_color" />             </shape>         </layer-list>     </item> <!--     <item android:state_focused="true" android:state_selected="false" android:state_activated="false">         <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">             <corners android:radius="8dp" />             <stroke android:width="1dp" android:color="#044400" />             <solid android:color="@color/edit_text_color" />         </shape>     </item>     <item android:state_focused="false" android:state_selected="true">         <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">             <corners android:radius="8dp" />             <stroke android:width="1dp" android:color="#044400" />             <solid android:color="@color/edit_text_color" />         </shape>     </item>  -->    <item android:state_focused="false">         <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">             <corners android:radius="8dp" />             <stroke android:width="1dp" android:color="#044400" />             <solid android:color="@color/edit_text_color" />         </shape>     </item> </selector> 

the idea i've come i've learned can detect if view in touch mode programmatically , use decide wether or not show focus highlighting. have xml drawable draws box focus recode in java custom drawable problem drawable cannot query touch mode nor have access view. there other options?


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -