2015-03-18 58 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" />