2016-03-09 71 views
2

我尝试了很多。但是毫无效果,我使用coodinatorlayout.I也用android:layout_alignParentBottom="true" 但它无法正常工作 我的应用程序bar_xml是如何把工具栏放在应用程序的底部?

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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" 
    tools:context="com.ezybzy.ezybzy.subcategory"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar_bottom" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:background="?attr/colorPrimary" 
      android:layout_alignParentBottom="true" 
      android:minHeight="?attr/actionBarSize" 
      /> 
    </android.support.design.widget.AppBarLayout> 

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

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

和活动的主要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_categories" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:menu="@menu/activity_main2_drawer" 
     android:layout_marginTop="?attr/actionBarSize"/> 

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

,但我得到这个唯一的.. but I got this only.. 我想在底部的工具栏.. 我试过它的内容main.Then它的工作,但酒吧的宽度不包括父宽度。但我不需要在内容主要填充0dp

我的内容的XML是

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.ezybzy.ezybzy.subcategory" 
    tools:showIn="@layout/app_bar_subcategory" 
    android:background="#ffffff"> 


</RelativeLayout> 
+0

其中是您的** content_subcategory **的xml? –

+0

但一些用户友好的应用程序使用工具栏在底部是不是? @Tim Castelijns –

回答

2

我对您的问题suggetion。我添加一个AppBarLayout如下:

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_bottom" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     android:paddingTop="8dp" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

通知:设置这个AppBarLayout与layout_gravity = “底部|结束”。 希望能帮到你。

+0

不,我现在做的当前动作栏也向下移动..我想要两个动作栏..一个在顶部和其他底部。 –

+0

@KBJ,我的建议是,你仍然保留一个AppBarLayout layout_gravity =“top | start”的工具栏,并添加其他工具栏AppBarLayout layout_gravity =“bottom | end”。 – dolphin

+0

它的工作我的朋友..谢谢.. –

相关问题