2015-03-18 60 views
0

我的工具欄顯示何時加載,但我的mapfragment覆蓋它,它不再可見。這裏是我的佈局:工具欄顯示負載,但消失

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
<android.support.v7.widget.Toolbar 
     android:id="@+id/top_bar" 
     android:layout_width="match_parent" 
     android:layout_height="60dp"/> 
<fragment 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:name="com.google.android.gms.maps.MapFragment"/> 

<android.support.v7.widget.Toolbar 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:layout_alignParentBottom="true" 
     android:background="@color/white_80_opacity"> 

    <ImageView 
      android:id="@+id/play_icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_play_icon" 
      android:adjustViewBounds="true" 
      android:maxHeight="50dp" /> 

    <ImageView 
      android:id="@+id/reduce_screen_icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_fullscreen_exit_48dp" 
      android:adjustViewBounds="true" 
      android:maxHeight="50dp" 
      android:layout_gravity="right" 
      android:paddingRight="8dp" /> 

</android.support.v7.widget.Toolbar> 
</RelativeLayout> 

<ImageView 
     android:id="@+id/adview" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:background="#708090" /> 

在代碼中,我設定的第一個工具欄:

Toolbar toolbar = (Toolbar) findViewById(R.id.top_bar); 
    toolbar.setTitle("State College"); 

    setSupportActionBar(toolbar); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    getSupportActionBar().setHomeButtonEnabled(true); 

任何想法?

回答

0

我需要將我的工具欄移動到佈局文件的底部。我認爲它就像是一個Z指數因素。這是我更新的文件。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

<fragment 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:name="com.google.android.gms.maps.MapFragment"/> 

<android.support.v7.widget.Toolbar 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:layout_alignParentBottom="true" 
     android:background="@color/white_80_opacity"> 

    <ImageView 
      android:id="@+id/play_icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_play_icon" 
      android:adjustViewBounds="true" 
      android:maxHeight="50dp" /> 

    <ImageView 
      android:id="@+id/reduce_screen_icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_fullscreen_exit_48dp" 
      android:adjustViewBounds="true" 
      android:maxHeight="50dp" 
      android:layout_gravity="right" 
      android:paddingRight="8dp" /> 

</android.support.v7.widget.Toolbar> 

<android.support.v7.widget.Toolbar 
     android:id="@+id/top_bar" 
     android:layout_width="match_parent" 
     android:layout_height="60dp"/> 

</RelativeLayout> 

<ImageView 
     android:id="@+id/adview" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:background="#708090" />