首页 > 解决方案 > 工具栏盲片

问题描述

我的项目我使用工具栏但工具栏盲片段

如何解决这个问题 sry 这段代码详细信息 ry 这段代码详细信息 ry 这段代码详细信息 ry 这段代码详细信息 ry 这段代码详细信息 ry 这段代码详细信息 ry 这段代码详细信息详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息ry 这段代码详细信息代码详情 ry 这段代码详情 ry 这段代码详情 ry 这段代码详情 ry 这段代码详情 ry 这段代码详情 ry 这段代码详情 ry 这段代码详情 ry 这段代码详情

在此处输入图像描述您可以排除边距吗?

在此处输入图像描述

这个代码我怎么能改变这个?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_marginStart="0dp"
        android:elevation="2dp"
        android:minHeight="?attr/actionBarSize"
        android:background="@drawable/ic_bar_start">
    </Toolbar>

    <fragment
        android:id="@+id/map_viewer_start"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        tools:context=".fragment.StartFragment" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="center"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="30dp">

        <Button
            android:id="@+id/mainStartRunning"
            android:layout_width="100dp"
            android:layout_height="40dp"
            android:text="RUNNING"
            style="@style/buttonTextRedText"
            android:background="@drawable/button_empty_background"
            android:onClick="onClick"
            android:layout_margin="10dp"
            android:gravity="center"/>

        <Button
            android:id="@+id/mainStartRacing"
            android:layout_width="100dp"
            android:layout_height="40dp"
            android:text="RACING"
            style="@style/buttonText"
            android:background="@drawable/button_background"
            android:onClick="onClick"
            android:layout_margin="10dp"
            android:gravity="center"/>

    </LinearLayout>
    </LinearLayout>
</RelativeLayout>

标签: androidandroid-studiokotlin

解决方案


使用如下layout_below属性_RelativeLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Toolbar
        android:id="@+id/toolbar"
        android:layout_alignParentTop="true"
        ...>
    </Toolbar>

    <LinearLayout
        android:layout_below="@+id/toolbar"
        android:layout_above="@+id/bottom_layout"
        ...>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottom_layout"
        android:layout_alignParentBottom="true"
        ...>

    </LinearLayout>
</RelativeLayout>

LinearLayoutorientation垂直使用

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

    <Toolbar
        ...>
    </Toolbar>


    <LinearLayout
        ...>


</LinearLayout>

推荐阅读