2015-04-07 90 views
0

中創建底部欄對於我的音樂應用程序,我想添加一個底欄作爲當前回放顯示。因爲我想爲所有片段使用一個片段,所以我只想將它添加到MainActivity中。但我不知道如何在佈局方式中做到這一點。你可以幫我嗎?如何在材質主題抽屜活動

<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:fitsSystemWindows="true" 
android:background="@color/sonatic_darker" 
android:layout_height="match_parent"> 

<!-- Framelayout to display Fragments --> 
<FrameLayout 
    android:id="@+id/frame_container" 
    android:fitsSystemWindows="true" 
    android:clipToPadding="true" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<!-- 
<ListView 
    android:id="@+id/list_slidermenu" 
    android:fitsSystemWindows="true" 
    android:clipToPadding="false" 
    android:layout_width="270dp" 
    android:layout_height="fill_parent" 
    android:layout_gravity="start" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="1dp" 
    android:listSelector="@drawable/list_selector" 
    android:background="@drawable/sidebar_background_xml"/> --> 

<RelativeLayout 
    android:id="@+id/relative_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/sidebar_background_xml" 
    android:layout_gravity="start" > 

    <ListView 
     android:id="@+id/list_slidermenu" 
     android:fitsSystemWindows="true" 
     android:clipToPadding="false" 
     android:layout_width="270dp" 
     android:layout_height="fill_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="1dp" 
     android:listSelector="@drawable/list_selector" 
     android:background="@android:color/transparent"/> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:layout_alignParentBottom="true" > 

     <ImageView 
      android:id="@+id/profile_image" 
      android:layout_width="25dp" 
      android:clipToPadding="true" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 
      android:layout_alignParentLeft="true" 
      android:layout_centerInParent="true" 
      android:layout_marginLeft="17dp" 
      android:layout_marginRight="24dp" 
      android:src="@drawable/ic_sonatic" 
      android:layout_centerHorizontal="true" /> 

     <TextView 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      android:clipToPadding="true" 
      android:fontFamily="sans-serif-light" 
      fontPath="SeraRegular.ttf" 
      android:layout_toRightOf="@id/profile_image" 
      android:minHeight="?android:attr/listPreferredItemHeightSmall" 
      android:textAppearance="?android:attr/textAppearanceListItemSmall" 
      android:textColor="@color/list_item_title_selected" 
      android:textColorHighlight="@color/list_item_title_selected" 
      android:gravity="center_vertical" 
      android:textSize="18sp" 
      android:text="@string/app_name" 
      android:paddingRight="10dp"/> 

     <TextView android:id="@+id/counter" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 
      android:clipToPadding="true" 
      android:background="@android:color/transparent" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      fontPath="SeraRegular.ttf" 
      android:layout_marginRight="8dp" 
      android:textColor="#FFFFFF"/> 

    </RelativeLayout> 
</RelativeLayout> 

回答

1

嘿遵循抽屜佈局按照您的需求,下面的代碼,

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

     <LinearLayou 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <FrameLayout 
       android:id="@+id/container" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" /> 

      <LinearLayou 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 
       <!--your bottom bar elements--> 
      </LinearLayou> 

     </LinearLayou> 

     <!--your drawer menu--> 
     <ListView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"></ListView> 
</android.support.v4.widget.DrawerLayout>