如何将Google地图视图放置在底部工具栏正上方?

3
我希望我的视图看起来像这样:enter image description here 这是我的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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="app.com.sampledesign.SwitchModeActivity"
    tools:showIn="@layout/activity_switch_mode">
    <com.sothree.slidinguppanel.SlidingUpPanelLayout
       xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoPanelHeight="40dp"
    sothree:umanoShadowHeight="4dp"
    sothree:umanoParallaxOffset="100dp"
    sothree:umanoDragView="@+id/contentLayout"
    sothree:umanoOverlay="true"
   >
    <!-- MAIN CONTENT -->
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/framelayout"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout">
    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/switch1"
        android:layout_marginLeft="5dp" />

    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/switch2"
        android:layout_marginLeft="40dp" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:background="@drawable/ic_fb"
        android:layout_marginLeft="70dp" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView2"
        android:background="@drawable/ic_twitter" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="false"
    android:layout_marginTop="10dp"
    android:id="@+id/linearLayout2">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Last-320"
        android:id="@+id/textView2"
        android:layout_marginLeft="150dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ever"
        android:id="@+id/textView3"
        android:layout_marginLeft="30dp" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="20dp"
    android:id="@+id/linearLayout3">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Max.Velocity"
        android:id="@+id/textView4" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Label"
        android:id="@+id/textView5"
        android:layout_marginLeft="70dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Label"
        android:id="@+id/textView6"
        android:layout_marginLeft="25dp" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="20dp"
    android:id="@+id/linearLayout4">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Max.G-Force"
        android:id="@+id/textView7" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Label"
        android:id="@+id/textView8"
        android:layout_marginLeft="70dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Label"
        android:id="@+id/textView9"
        android:layout_marginLeft="25dp" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout4"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="20dp"
    android:id="@+id/linearLayout5">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Max.G-Force"
        android:id="@+id/textView10" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Label"
        android:id="@+id/textView11"
        android:layout_marginLeft="70dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Label"
        android:id="@+id/textView12"
        android:layout_marginLeft="25dp" />
</LinearLayout>

<com.github.mikephil.charting.charts.LineChart
    android:id="@+id/chart1"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:layout_below="@+id/linearLayout5"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="30dp" />

        </LinearLayout>

    </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:orientation="vertical"
        android:clickable="true"
        android:focusable="false"
        android:id="@+id/contentLayout">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

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

    <include android:id="@+id/toolbar_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            layout="@layout/toolbar"
            ></include>
    </LinearLayout>


</com.sothree.slidinguppanel.SlidingUpPanelLayout>

 </RelativeLayout>

目前我的地图视图下面没有工具栏。我希望在工具栏开始之前,地图可以向上滑动并折叠。只显示地图而不显示工具栏。
以下是我的Toolbar.xml:
<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_bottom"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:background="#ffffff"
    android:layout_alignParentBottom="true"
    android:minHeight="?attr/actionBarSize"
    android:layout_marginBottom="5dp">

<LinearLayout
    android:id="@+id/toolbarmenucontainer"
    android:layout_width="match_parent"
    android:weightSum="3"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@drawable/ic_location"
        android:clickable="true"
        android:scaleType="fitXY"
        android:layout_weight="1"
        />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@drawable/ic_setting"
        android:clickable="true"
        android:scaleType="fitXY"
        android:layout_weight="1"
        />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@drawable/ic_people"
        android:clickable="true"
        android:scaleType="fitXY"
        android:layout_weight="1"
        />

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

我在视图中遇到了一个问题。

1个回答

1
尝试将ToolBar放在底部,放在SlidingUpPanelLayout之外。将其属性alignParentBottom设置为“true”。然后使用android:layout_above="@+id/toolbar_bottom"使SlidingUpPanelLayoutToolBar对齐并位于其上方。

感谢您的回复,但按照您所说的做法将使整个内容(除了工具栏)不可见。 - Anand
你能解释一下为什么它在我测试时没有起作用吗?顺便说一下,我已经使用了你正确的ID“toolbar_bottom”编辑了答案。抱歉。 - speirs23
先生,我不知道为什么,但我们只得到了工具栏,而且我已经将它包含在我们的视图中。可能是工具栏占据了整个视图。 - Anand

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接