2017-10-04 5 views
0

복제물을 표시하기 전에 제 질문을 읽어보십시오.네비게이션 서랍에 항목을 추가하십시오

탐색 서랍의 첫 번째 단추에 대한 사용자 지정 레이아웃을 만들었지 만 탐색 서랍 항목 목록에 어떻게 포함시킬 수 있습니까? 다른 모든 단추는 기본값으로 바뀌므로 첫 번째 단추 레이아웃 만 변경하고 싶습니다.

+0

시각화 수, 정확히 무엇을 줄까? –

답변

0

아무 문제없이 그냥 맞춤 서랍을 만드세요. 그래서 homeActivity 또는 main으로 시작하십시오. 사용자 정의 탐색보기 단지 동적 콘텐츠에 대한 귀하의 행 항목을 물론 그런

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.NavigationView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="@color/nav_drawer_list_background" 
    android:fitsSystemWindows="true"> 

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

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/navDrawerItemRecyclerView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@+id/llVersion" 
      android:scrollbars="none" /> 

     <LinearLayout 
      android:id="@id/llVersion" 
      android:layout_width="match_parent" 
      android:gravity="center" 
      android:layout_alignParentBottom="true" 
      android:layout_height="@dimen/nav_drawer_version_height"> 

      <ImageView 
       android:id="@+id/imgBottomLogo" 
       android:layout_width="@dimen/nav_drawer_bottom_logo_width" 
       android:layout_height="@dimen/nav_drawer_bottom_logo_height" 
       android:src="@drawable/img_ap_menu_logo" /> 

      <TextView 
       android:id="@+id/txtVersion" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="@color/white" 
       android:layout_gravity="center" 
       android:layout_marginBottom="@dimen/nav_drawer_version_margin_bottom" 
       android:textSize="@dimen/nav_drawer_version_text_size" 
       android:layout_marginLeft="@dimen/nav_drawer_version_margin_left" 
       android:text="@string/nav_drawer_version_text"/> 

     </LinearLayout> 



    </RelativeLayout> 

</android.support.design.widget.NavigationView> 

과 서랍의 recyclerview를 채우는 어댑터에 대한 다음

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    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" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical" 
    android:background="@color/colorPrimaryDark"> 

    <include layout="@layout/fragment_toolbar"/> 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawerlayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:openDrawer="start"> 

     <!-- FrameLayout is used to insert fragments to display --> 
     <FrameLayout 
      android:id="@+id/fragPlaceholder" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

     <!--Left Side Drawer Sliding Menu--> 
     <fragment 
      android:id="@+id/navDrawerFragment" 
      android:name="com.appstudio35.fragments.NavDrawerFragment" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:orientation="vertical" 
      tools:layout="@layout/fragment_nav_drawer" /> 

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

</LinearLayout> 

.

행 항목 예 :

 <?xml version="1.0" encoding="utf-8"?> 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      style="@style/SelectableItemBackground" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:paddingBottom="@dimen/nav_drawer_item_padding_bottom" 
       android:paddingTop="@dimen/nav_drawer_item_padding_top" 
       android:paddingStart="@dimen/nav_drawer_padding_start" 
       android:paddingEnd="@dimen/nav_drawer_padding_end" 
       android:gravity="center" 
       tools:background="@color/nav_drawer_list_background"> 

       <RelativeLayout 
        android:layout_width="@dimen/nav_drawer_item_icon_width" 
        android:layout_height="wrap_content"> 

        <ImageView 
         android:id="@+id/imgMenuIconDefault" 
       android:layout_width="@dimen/nav_drawer_item_menu_icon_width" 
      android:layout_height="@dimen/nav_drawer_item_menu_icon_height" 
         tools:src="@drawable/ic_ap_capture_media" 
         tools:visibility="invisible"/> 

        <ImageView 
         android:id="@+id/imgMenuIconSelected"    android:layout_width="@dimen/nav_drawer_item_menu_icon_width"   android:layout_height="@dimen/nav_drawer_item_menu_icon_height"/> 

       </RelativeLayout> 

       <TextView 
        android:id="@+id/txtMenuName" 
        style="@style/AutoPointTheme.TextView.Medium.Medium" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textAllCaps="false" 
        android:text="@string/example_nav_drawer_item"/> 

      </LinearLayout> 

      <View 
       android:id="@+id/menuDivider" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/nav_drawer_menu_divider_height" 
       android:background="@color/dividerColor" /> 

     </LinearLayout> 
Hope that helps.