2015-10-13 68 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>