Onfocuschangelistener 在XML中丢失对布局的关注时隐藏布局

Onfocuschangelistener 在XML中丢失对布局的关注时隐藏布局,onfocuschangelistener,onclick,android,layout,tabs,lost-focus,Onfocuschangelistener,Onclick,Android,Layout,Tabs,Lost Focus,我有以下xml文件: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/FrameLayout" android:layout_width="match_parent" android:layout_height="match_parent" >

我有以下xml文件:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/FrameLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
</android.support.v4.view.ViewPager>

<LinearLayout
    android:id="@+id/musicLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:gravity="center"
    android:orientation="horizontal"
    android:padding="10dp"
    android:focusable="true"
    android:visibility="visible" >

    <ImageView
        android:id="@+id/backward"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/backward" />

    <ImageView
        android:id="@+id/stop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:src="@drawable/stop" />

    <ImageView
        android:id="@+id/pausePlay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:src="@drawable/play" />

    <ImageView
        android:id="@+id/forward"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:paddingRight="10dp"
        android:src="@drawable/forward" />

</LinearLayout>

在musicLayout和pageviewer中,但什么都没有发生!我做错了什么
编辑:

如果有帮助,每个选项卡都是一个片段,具有自己的布局,并添加到viewPager中。

我认为解决此问题的最简单方法是添加一个与视图组父级匹配的透明视图。基本上,ViewPager、LinearLayout和View处于同一级别。然后,您可以在透明视图上注册onClickListener,这样就可以了

布局应该如此简单:

<View android:id="@+id/transparent_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:clickable="true"/>


谢谢,我会检查它,如果它有效,我会接受你的答案。非常感谢!它是有效的,但是只有当我把视线放在视窗和LinearLayout中间时!我还在视图中创建了android:clickable=“true”。我必须提到的另一件事是,为了在linearLayout消失后使用backround布局,必须将视图的可见性更改为gone,并在启用linearLayout时再次启用它。