2014-11-09 6 views
1

내 앱 UI에서 작업 중이며 탐색 창을 구현할 때 문제가 있습니다. here에서 볼 수 있듯이 내 미디어 플레이어를 관리 할 수있는 버튼이 있습니다. 내비게이션 서랍을 구현할 때 내 클릭에 응답하지 않습니다 (내비게이션 서랍없이 잘 작동 함).NavigationDrawer가 활동의 다른 버튼을 차단합니다.

Java에서 구현을 삭제할 때 변경이 없으므로 XML 파일에서 문제가 발생한다고 생각합니다.

main_activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MyActivity"> 

    <fragment 
     android:id="@+id/fragments" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.example.ilan.myapplication.fragments.FragmentHome" > 
    </fragment> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:text="Buffering" 
     android:id="@+id/tV_Buffering" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentEnd="true" /> 

    <include 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     android:layout_weight="1" 
     layout="@layout/player_controls" 
     android:layout_alignParentBottom="true"/> 

    <include 
     layout="@layout/navigation_drawer_main_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

</RelativeLayout> 

주 나는 모든 활동을 충당하기 위해 그것을 가지고 결국 내비게이션 창을 넣어 : 여기

내 XML 시트입니다.

navigation_drawer_main_layout.xml

<?xml version="1.0" encoding="utf-8"?> 

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <ListView android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     android:background="#FFFFFF"/> 
</android.support.v4.widget.DrawerLayout> 

player_controls.xml

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/blue"> 

     <Button 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:id="@+id/button_play_pause" 
      android:layout_toStartOf="@+id/tV_Buffering" 
      android:background="@drawable/bouton_play" 
      android:layout_centerInParent="true" 
      /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Stop" 
      android:id="@+id/button_stop" 
      android:layout_toRightOf="@id/button_play_pause" 
      android:layout_centerInParent="true" 
      android:layout_marginLeft="20dp"/> 
</RelativeLayout> 

글쎄, 누군가가 좋지 않을까에서이 올 곳에서 어떤 생각이 있다면, 감사합니다!

+0

을 대신 player_controls 등의 main_activity의 일부 조각 –

+0

@VyprNoch I의 일부로 구현으로 이것이 어떻게 다른지 이해하지 못하겠습니까? 내 문제는이게 아무것도 영향을 미치지 않는다는 뜻이야? 그렇지 않으면 내비게이션 서랍을 사용할 때 단편 만 사용해야한다는 것을 암시 할 수 있기 때문에 플레이어가 항상 활동에 참여하게됩니다. – ilansas

+0

"navigation_drawer_main_layout"이 "player_controls"위에 있으므로 클릭/터치 이벤트가 발생했을 수 있습니다. android.support.v4.widget.DrawerLayout "에서 android : layout_width ="xx dp "로 layout_width ="match_parent "를 변경하십시오 (** xx **가 "재생 버튼"을 숨기지 않음) – Rami

답변

0

DrawerLayout을 사용하려면 기본 콘텐츠 뷰를 너비와 높이가 match_parent이고 layout_gravity가없는 첫 번째 자식으로 배치하십시오. 서랍을 메인 콘텐츠보기 다음에 하위보기로 추가하고 layout_gravity를 적절하게 설정합니다. 서랍에서는 일반적으로 높이가 고정 너비 인 경우 match_parent를 사용합니다. DrawerLayout에 관한 google의 문서를 확인하십시오 : https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html.

기본 콘텐츠는 RelativeLayout 내부에 DrawerLayout을 포함하는 대신 DrawerLayout 내부에 넣어야합니다. 귀하의 경우를 들어

, 당신은 대신이 방법을 구현하기 위해 시도 할 수 :

main_activity.xml

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

    <RelativeLayout 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".MyActivity"> 

     <fragment 
      android:id="@+id/fragments" 
      class="com.example.ilan.myapplication.fragments.FragmentHome" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
     </fragment> 


     <TextView 
      android:id="@+id/tV_Buffering" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentTop="true" 
      android:text="Buffering" 
      android:textAppearance="?android:attr/textAppearanceSmall"/> 

     <include 
      layout="@layout/player_controls" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_alignParentBottom="true" 
      android:layout_weight="1"/> 

    </RelativeLayout> 

    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <ListView 
     android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="#FFFFFF" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp"/> 
</android.support.v4.widget.DrawerLayout> 
관련 문제