Android-UI:使用硬件 keyboard/barcode 扫描仪时没有焦点标记

Android-UI: No focus marker when using hardware keyboard/barcode scanner

目前我正在开发一个使用条形码 reader 来扫描条形码的应用程序。条形码 reader 被 android 识别为硬件键盘。效果很好,我可以读取条形码。但是,当我阅读条形码时,AppBar 中的 Hamburger 会获得焦点(请参见屏幕截图)。 我怎样才能摆脱那个焦点标记?我试图将焦点设置到另一个控件,但这不起作用。是否可以覆盖焦点标记的样式?

截图:http://postimg.org/image/7zmzzhstx/

在再次解决该问题后,我找到了一个适合我的解决方案。也许这可以帮助其他人:

在我的 activity 中,我覆盖了 public boolean dispatchKeyEvent(KeyEvent event) 方法来处理来自条形码扫描仪的输入。我现在添加了以下代码行:

containerContent.requestFocus();

containerContent 控件只是一个 FrameLayout,其中托管了我的片段。在发布此问题之前,我已经尝试过了。但它不起作用,因为 FrameLayout 是 "not allowed" 来请求焦点。现在我也修改了我的布局 xml:

<FrameLayout
    android:id="@+id/containerMain"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true"
    android:focusableInTouchMode="true">
</FrameLayout>

添加了 android:focusable="true"android:focusableInTouchMode="true",现在可以使用了!