2015-10-13 66 views
-2

如何将一个按钮添加到DrawLayout,此代码用于显示谷歌地图,并且我需要在地图底部添加一个按钮。Android XML DrawLayout

<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" 
      tools:context=".MainActivity" > 


     <FrameLayout 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 


      <fragment 
       android:id="@+id/navigation_drawer" 
       android:name="com.lia.sonorMap.NavigationDrawerFragment" 
       android:layout_width="@dimen/navigation_drawer_width" 
       android:layout_height="match_parent" 
       android:layout_gravity="start" 
       tools:layout="@layout/fragment_navigation_drawer" /> 

<Button 
     android:id="@id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" 
     android:layout_alignParentBottom="true"/> 
     </android.support.v4.widget.DrawerLayout> 

感谢

+0

把片段,并在垂直的LinearLayout按钮,移动'机器人:layout_gravity =“启动“'LinearLayout的属性。 –

+0

我做到了,但不会在电话上工作,错误 – user3020848

回答

0

您可以添加相对布局内的按钮

<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" 
tools:context=".MainActivity" > 


<FrameLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 


<fragment 
    android:id="@+id/navigation_drawer" 
    android:name="com.lia.sonorMap.NavigationDrawerFragment" 
    android:layout_width="@dimen/navigation_drawer_width" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    tools:layout="@layout/fragment_navigation_drawer" /> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="@color/Azure"> 

<Button 
    android:id="@id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Button" 
    android:layout_alignParentBottom="true"/> 
</RelativeLayout> 
</android.support.v4.widget.DrawerLayout>