2014-10-30 1 views
7

내비게이션 서랍이있는 내 앱에 Material Design을 구현합니다. Nav의 모든 구현이 다릅니다. 머티리얼 디자인을 포함한 서랍 및 툴바 (see this post); 앱을 ICS/Halo 디자인과 비슷한 느낌으로 유지하고 툴바 아래에서 탐색 드로어를 슬라이드 아웃하도록 선택했습니다. 문제는 탐색 함이 열려있을 때 툴바가 나머지 활동과 마찬가지로 그림자와 함께 어두워지는 것입니다. 툴바를 어둡게 유지하는 방법은 무엇입니까? 위에 링크 된 게시물의 이미지를 보면 # 6, 3 또는 5 이후이지만 # 9와 비슷한 모양이되었습니다.탐색 서랍이 열려있을 때 툴바에서 그림자 제거 - 재질 디자인 지원 라이브러리

예 (위의 포스트에서) :

내가 (도구 모음에서 그림자) 후있어 무엇 :

enter image description here

나는 현재 (탐색 서랍이 열려있을 때 도구 모음이 어두워) 무엇을 얻을 : 여기

enter image description here

내 주요 활동의 XML 코드입니다 :

그 ID 'container'<FrameLayout> 내 모든 단편이 팽창되는 경우, 그리고 콘텐츠가 툴바 아래 것이 너무가 marginTop가 툴바의 높이로 설정하는 것이되는 주목할 부분

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="com.funkhaus.navdrawer.app.MainActivity"> 

<!-- As the main content view, the view below consumes the entire 
    space available using match_parent in both dimensions. --> 
<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!-- We use a Toolbar so that our drawer can be displayed 
     in front of the action bar; Added for Material Design --> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/my_awesome_toolbar" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:minHeight="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" /> 

    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="?attr/actionBarSize" /> 

</FrameLayout> 

<fragment android:id="@+id/navigation_drawer" 
    android:layout_width="@dimen/navigation_drawer_width" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?attr/actionBarSize" 
    android:fitsSystemWindows="true" 
    android:layout_gravity="start" 
    android:name="com.funkhaus.brewwerks.NavigationDrawerFragment" /> 
. 마찬가지로 탐색 드로어 조각의 도구 모음 높이가으로 설정되어 그 아래로 슬라이드합니다.

+1

DrawerLayout 외부에 도구 모음을 배치하십시오. – alanv

+0

내 이해에 따라 네비게이션 드로어를 사용할 때''이 루트 뷰 여야합니다 – Flash

+1

콘텐츠 루트, 예. 툴바 루트가 아닙니다. – alanv

답변

9

@alanv 덕분에 문제가 해결되었습니다.

위의 내 게시물은 내 activity_main.xml 코드를 보여줍니다. 나는 도구 모음보기를 제거하고 marginTop 서식을 제거,이 그것을 단순화 :

<android.support.v4.widget.DrawerLayout 
    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" 
    android:fitsSystemWindows="true" 
    tools:context="com.funkhaus.navdrawer.app.MainActivity"> 

<!-- As the main content view, the view below consumes the entire 
    space available using match_parent in both dimensions. --> 
    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <fragment android:id="@+id/navigation_drawer" 
     android:layout_width="@dimen/navigation_drawer_width" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     android:layout_gravity="start" 
     android:name="com.funkhaus.brewwerks.NavigationDrawerFragment" /> 

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

나는 toolbar.xml을 만들었을 것을 <include> 's를 activity_main.xml 위 내 주요 활동에 나는 지금 된 setContentView() :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:orientation="vertical"> 
    <!-- We use a Toolbar so that our drawer can be displayed 
      in front of the action bar; Added for Material Design --> 
    <android.support.v7.widget.Toolbar 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/my_awesome_toolbar" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:minHeight="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" /> 

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

</LinearLayout> 

마지막으로, toolbar.xml 내 활동의 onCreate() I setContentView()에서 :

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.toolbar); 
    // Rest of code here.... 
+1

ActionBar가 계속 지원됩니다. 왜 대신 사용하지 않으시겠습니까? 그것은 그것과 똑같이 행동합니다. – CristianGuerrero

+1

정말 고마워! @ The Funk – theknut

+0

업데이트 된 Material Design Guidelines에 대해 의도적으로 Navigation Drawer를 설계하고 있지만 http://www.google.com/design/spec/patterns/navigation-drawer에 대한 링크가 있습니다. HTML – Flash

2
You do it in the same xml like this, This is for underlying toolbar navigation like play store app design 




    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="com.ccas.roadsideconnect.BaseFragmentActivity"> 
    <android.support.v4.widget.DrawerLayout 

     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 


     <FrameLayout 
      android:id="@+id/main_fragment_container" 
      android:layout_marginTop="?attr/actionBarSize" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 



     <FrameLayout android:id="@+id/navigation_drawer" 
      android:layout_width="@dimen/navigation_drawer_width" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      tools:layout="@layout/fragment_navigation_drawer" /> 
    </android.support.v4.widget.DrawerLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="@drawable/img_actionbar_white_sm" 
       android:gravity="top" 
       android:minHeight="58.0dip" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
       /> 
     </LinearLayout> 

    </FrameLayout> 

아래 코드는 Gmail APP 디자인과 같은 툴바 탐색을위한 코드입니다.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.ccas.roadsideconnect.BaseFragmentActivity"> 
<android.support.v4.widget.DrawerLayout 

    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <FrameLayout 
     android:id="@+id/main_fragment_container" 
     android:layout_marginTop="?attr/actionBarSize" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@drawable/img_actionbar_white_sm" 
      android:gravity="top" 
      android:minHeight="58.0dip" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
      /> 
    </LinearLayout> 

    <FrameLayout android:id="@+id/navigation_drawer" 
     android:layout_width="@dimen/navigation_drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     tools:layout="@layout/fragment_navigation_drawer" /> 
</android.support.v4.widget.DrawerLayout> 

</FrameLayout> 
관련 문제