2017-05-09 51 views

回答

0

裏面你activity_main.xml中,

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.DrawerLayout 
    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:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 
    <include layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true"> 
     <android.support.design.widget.NavigationView 
      android:layout_above="@+id/llBottomLay" 
      android:id="@+id/nav_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 

     <LinearLayout 
      android:id="@+id/llBottomLay" 
      android:layout_alignParentBottom="true" 
      android:layout_width="match_parent" 
      android:layout_height="55dp" 
      android:background="#e6e6e6" 
      android:orientation="horizontal"> 
      <!--place your things here--> 
     </LinearLayout> 
    </RelativeLayout> 
</android.support.v4.widget.DrawerLayout> 

*的ID llBottomLay需要的LinearLayout由親屬或其他選項,根據您的需要

+0

這不是我的工作的情況下,給出了錯誤。 –

+0

你正在收到什麼錯誤? – Exigente05

0

嘗試是這樣的替換:

<?xml version="1.0" encoding="utf-8"?> 
<merge> 
    <android.support.v4.widget.DrawerLayout> 
    ...removed for brevity... 
    </android.support.v4.widget.DrawerLayout> 
    <TextView 
    ...your required properties... 
     android:gravity="bottom" android:layout_gravity="bottom"/> 
</merge> 
0

請嘗試以下代碼: -

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="@color/side_menu_bg_color" 
    android:fitsSystemWindows="false" 
    android:scrollbars="none" 
    android:theme="@style/NavigationDrawerStyle" 
    app:headerLayout="@layout/nav_header_mains" 
    app:itemTextAppearance="@style/NavigationDrawer" 
    app:itemTextColor="@color/White" 
    app:menu="@menu/activity_main_drawer" 
    app:selectableItemBackground="@drawable/nav_drawer_item_selector"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:clickable="true" 
     android:orientation="vertical"> 

     <include layout="@layout/nav_bar_playback_controls" /> // This is bottom layout with black background and 2 textviews 
    </LinearLayout> 
</android.support.design.widget.NavigationView> 

nav_bar_playback_controls.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/Black" 
    android:padding="10dp"> 

    <TextView 
     android:id="@+id/artist" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:ellipsize="end" 
     android:maxLines="1" 
     android:paddingRight="5dp" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="@color/White" 
     android:text="Demo text" 
     android:textSize="23px" 
     android:textStyle="bold" 
     android:typeface="sans" /> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/artist" 
     android:layout_marginTop="4dp" 
     android:layout_toLeftOf="@+id/play_pause" 
     android:ellipsize="end" 
     android:text="Hello there" 
     android:maxLines="2" 
     android:paddingRight="5dp" 
     android:textColor="@color/White" 
     android:textSize="31px" 
     android:textStyle="bold|normal" 
     android:typeface="sans" /> 

    <ImageButton 
     android:id="@+id/play_pause" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:background="@null" 
     android:padding="8dp" /> 
</RelativeLayout> 

Screenshot

+0

我試過這個,它完美的作品,謝謝。但是,它包含了我的導航抽屜項目,是否有可能在最底層(可滾動)像項目一樣實現該文本,以便用戶在頁面底部滾動時可以看到這些內容? –

+0

@ArdaÇebi:那麼在這種情況下,您可以將您的導航抽屜項目放在listview或recyclerview中,然後放置底部,將這兩個視圖放在相對佈局中,使用Relative佈局應用佈局的上方或下方佈局。這個技巧不會覆蓋菜單項,用戶可以正確地看到它。如果可能, – Bhavnik

+0

是否可以創建一個要點(例如項目等)? –