2013-02-12 4 views
5

에서 손실 될 때 레이아웃을 숨기기 나는 다음과 같은 XML 파일이 있습니다
그 초점이 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> 

FrameLayout이 위의 레이아웃에 viewpager있는 탭과 액션 바을 위해입니다. 액션 바가 완벽하게 작동합니다. 문제를 해결하고 싶습니다. 마지막 linearlayout은 실제로 화면 하단에 떠있는 미디어 플레이어로, linearlayout 바깥 쪽을 누를 때 숨겨져 있어야합니다. 나는 pageLayout의 과 pageviewer의 을 테스트했지만 아무 일도 일어나지 않았습니다! 내가 도대체 ​​뭘 잘못하고있는 겁니까?
편집 :
도움이 될 경우 모든 탭은 viewPager에 추가 된 자체 레이아웃이있는 조각입니다.

답변

2

이 문제의 가장 쉬운 해결책은 ViewGroup의 부모와 일치하는 투명한 뷰를 추가하는 것입니다. 기본적으로 ViewPager, LinearLayout 및 View는 같은 레벨에 있습니다. 그런 다음 투명 뷰에 onClickListener를 등록 할 수 있으며 그 트릭을 수행해야합니다.

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

덕분에 내가 그것을 확인하고 작동하는지 내가 답변을 받아 들일 것입니다 :

레이아웃이 같은 간단한해야한다. – user2065529

+0

많은 감사합니다! ViewPager와 LinearLayout의 중간에 뷰를 놓았을 때만 작동했습니다! 또한 뷰에서 android : clickable = "true"를 만들었습니다. 다시 말해서 linearLayout이 사라진 후에 backround 레이아웃을 사용하려면 lineralayout을 사용 가능하게 설정할 때 뷰의 가시성을 변경하고 다시 활성화해야한다는 것입니다. – user2065529

관련 문제