2015-01-03 5 views
0

앱 인터페이스 재질 디자인 도구 모음, 서랍, 팹이 모두 작동합니다. 그런 다음 두 개의 탭을 추가하기 위해 https://github.com/neokree/MaterialTabs 라이브러리를 사용했습니다. 이제 조각과 스 와이프 액션이 작동합니다. 그러나 이제 툴바가 사라지고 tabHost가 대신 사용됩니다. 안드로이드 스튜디오 디자인보기 (avd는 아님)에서 보여 주지만 실제 장치 (kitkat)에 왔을 때는 그렇지 않습니다. 나는 무엇이 잘못되었는지를 lib 모듈의 테스트와 같은 방식으로 구현했는지 모른다.탭을 구현하면 안드로이드 도구 모음이 숨겨집니다.

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 

xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/drawer" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context=".MyActivity"> 

<!-- The main content view --> 

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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <include 
      layout="@layout/toolbar" 
      android:id="@+id/toolbar" /> 


     <it.neokree.materialtabs.MaterialTabHost 
      android:id="@+id/tabHost" 
      android:layout_width="match_parent" 
      android:layout_height="48dp" 
      app:primaryColor="#009688" 
      app:accentColor="#2B4AE0" 
      android:layout_below="@+id/toolbar" /> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/tabHost" /> 


     <com.getbase.floatingactionbutton.FloatingActionsMenu 
      android:id="@+id/multiple_actions" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" 
      fab:fab_addButtonColorNormal="@color/primary" 
      fab:fab_addButtonColorPressed="@color/primary_pressed" 
      fab:fab_addButtonPlusIconColor="@color/white" 
      fab:fab_labelStyle="@style/menu_labels_style" 
      android:layout_marginBottom="16dp" 
      android:layout_marginRight="16dp" 
      android:layout_marginEnd="16dp"> 

      <com.getbase.floatingactionbutton.FloatingActionButton 
       android:id="@+id/action_a" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       fab:fab_colorNormal="@color/white" 
       fab:fab_title="Event" 
       fab:fab_icon="@drawable/ic_attendance" 
       fab:fab_colorPressed="@color/white_pressed" /> 

      <com.getbase.floatingactionbutton.FloatingActionButton 
       android:id="@+id/action_b" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       fab:fab_colorNormal="@color/white" 
       fab:fab_title="Message" 
       fab:fab_icon="@drawable/ic_message" 
       fab:fab_colorPressed="@color/white_pressed" /> 

      <com.getbase.floatingactionbutton.FloatingActionButton 
       android:id="@+id/action_c" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       fab:fab_colorNormal="@color/white" 
       fab:fab_title="Attendance" 
       fab:fab_icon="@drawable/ic_events" 
       fab:fab_colorPressed="@color/white_pressed" /> 

     </com.getbase.floatingactionbutton.FloatingActionsMenu> 


    </RelativeLayout> 
</FrameLayout> 
<!-- The navigation drawer --> 

<ListView 
    android:id="@+id/left_drawer" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:layout_marginTop="?attr/actionBarSize" 
    android:background="#F8F8F8" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0dp" 
    android:fitsSystemWindows="false" /> 

</android.support.v4.widget.DrawerLayout> 
+0

해결 했습니까? 나는 같은 문제를 가지고있다. Thx – user1140656

+0

광산이 현재 작동 중입니다. 그러나 나는 이것을 어떻게 고정 시켰는지 모른다. 원하는 경우 새 xml을 게시 할 수 있습니다. –

+0

좋아, XML을 게시, 감사합니다. it.neokree.materialtabs.MaterialTabHost의 새 버전을 사용하고 있습니까? –

답변

2

이것은 내가 사용한 전체 코드입니다. 여기서는 탭, 툴바 및 팹 라이브러리를 구현했습니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:fab="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 


    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context=".MyActivity"> 


    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <!-- The main content view --> 

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


      <RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 


       <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
        xmlns:app="http://schemas.android.com/apk/res-auto" 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="@dimen/abc_action_bar_default_height_material" 
        android:background="#2B4AE0" 
        app:theme="@style/ToolBarStyle"> 

        <TextView 
         android:id="@+id/headerText" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="@android:style/TextAppearance.Theme" 
         android:textColor="@android:color/white" /> 

        <RelativeLayout 
         android:id="@+id/notification" 
         android:layout_width="50dp" 
         android:layout_height="match_parent" 
         android:layout_gravity="end" 
         android:background="@drawable/butto_pressed" 
         android:clickable="true" 
         > 

         <ImageView 
          android:layout_width="20dp" 
          android:layout_height="20dp" 


          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:src="@drawable/bell_icon" /> 
        </RelativeLayout> 
       </android.support.v7.widget.Toolbar> 

       <RelativeLayout 
        android:id="@+id/frame" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/toolbar"> 

        <it.neokree.materialtabs.MaterialTabHost 
         android:id="@+id/tabHost" 
         android:layout_width="match_parent" 
         android:layout_height="48dp" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" 
         android:layout_alignParentTop="true" 
         app:accentColor="@color/blue" 


         app:primaryColor="@color/white" 
         app:textColor="@color/blue" /> 

        <android.support.v4.view.ViewPager 
         android:id="@+id/pager" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_below="@+id/tabHost" /> 


        <com.getbase.floatingactionbutton.FloatingActionsMenu 
         android:id="@+id/multiple_actions" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentBottom="true" 
         android:layout_alignParentEnd="true" 
         android:layout_alignParentRight="true" 
         android:layout_marginBottom="16dp" 
         android:layout_marginEnd="16dp" 
         android:layout_marginRight="16dp" 
         fab:fab_addButtonColorNormal="@color/primary" 
         fab:fab_addButtonColorPressed="@color/primary_pressed" 
         fab:fab_addButtonPlusIconColor="@color/white" 
         fab:fab_labelStyle="@style/menu_labels_style"> 

         <com.getbase.floatingactionbutton.FloatingActionButton 
          android:id="@+id/action_a" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          fab:fab_colorNormal="@color/white" 
          fab:fab_colorPressed="@color/white_pressed" 
          fab:fab_icon="@drawable/ic_attendance" 
          fab:fab_title="Announcement" /> 

         <com.getbase.floatingactionbutton.FloatingActionButton 
          android:id="@+id/action_b" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          fab:fab_colorNormal="@color/white" 
          fab:fab_colorPressed="@color/white_pressed" 
          fab:fab_icon="@drawable/ic_message" 
          fab:fab_title="Message" /> 

         <com.getbase.floatingactionbutton.FloatingActionButton 
          android:id="@+id/action_c" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          fab:fab_colorNormal="@color/white" 
          fab:fab_colorPressed="@color/white_pressed" 
          fab:fab_icon="@drawable/ic_events" 
          fab:fab_title="Attendance" /> 

        </com.getbase.floatingactionbutton.FloatingActionsMenu> 

       </RelativeLayout> 
      </RelativeLayout> 
     </FrameLayout> 
     <!-- The navigation drawer --> 

     <ListView 
      android:id="@+id/left_drawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:layout_marginTop="?attr/actionBarSize" 
      android:background="#F8F8F8" 

      android:choiceMode="singleChoice" 
      android:divider="@android:color/transparent" 
      android:dividerHeight="0dp" 
      android:fitsSystemWindows="false" /> 

    </android.support.v4.widget.DrawerLayout> 
</LinearLayout> 
관련 문제