Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 在coordinatorlayout中重叠视图大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
代码如下.当片段加载时,它会覆盖工具栏和我的浮动操作栏.我怎么处理这个?我想要工具栏显示.看来在coordinatorlayout中有一些重叠.我检查了这样的不同问题.似乎没有人回答我的问题
<?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/activity_horizontal_margin"
    android:orientation="vertical"
    tools:context="com.example.sAMMybobo.moglis.MoGLIsmaps"
    xmlns:android="http://scheR_667_11845@as.android.com/apk/res/android"
    xmlns:android="http://scheR_667_11845@as.android.com/apk/res-auto"
    xmlns:tools="http://scheR_667_11845@as.android.com/tools">

    <android.support.v7.widget.Toolbar
        android:layout_width="fill_parent"
        xmlns:android="http://scheR_667_11845@as.android.com/apk/res/android"
        android:layout_height="?attr/actionBarSize"
        android:id="@+id/toolbar"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        android:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

    <android.support.design.widget.FloaTingActionButton
        android:id = "@+id/fab"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:src = "@android:drawable/ic_input_add"
        android:layout_gravity = "bottom|end"
        app:fabSize = "mini">

    </android.support.design.widget.FloaTingActionButton>

    <fragment
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:id="@+id/main_map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        xmlns:android="http://scheR_667_11845@as.android.com/apk/res/android"
        tools:context = "com.example.sAMMybobo.moglis.MoGLIsmaps"
        xmlns:tools="http://scheR_667_11845@as.android.com/tools"
        />
 <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:BACkground="#fff"
        android:layout_gravity = "bottom"
        >
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="My LOCATIOn"
            android:onClick="observe"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text = "Friends"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text = "setTings"/>
    </LinearLayout>
    </android.support.design.widget.CoordinatorLayout>

解决方法

是因为在协调器布局中,您无法将一个视图设置为相对于另一个视图.您只能将它们与父级相关联.尝试下面的布局.
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://scheR_667_11845@as.android.com/apk/res/android"
    xmlns:android="http://scheR_667_11845@as.android.com/apk/res-auto"
    xmlns:tools="http://scheR_667_11845@as.android.com/tools"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:padding="@dimen/activity_horizontal_margin"
    tools:context="com.example.sAMMybobo.moglis.MoGLIsmaps">

    <RelativeLayout
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://scheR_667_11845@as.android.com/apk/res/android"
            android:id="@+id/toolbar"
            android:layout_width="fill_parent"
            android:layout_height="?attr/actionBarSize"
            android:elevation="4dp"
            android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>

        <fragment
            xmlns:android="http://scheR_667_11845@as.android.com/apk/res/android"
            xmlns:tools="http://scheR_667_11845@as.android.com/tools"
            android:id="@+id/main_map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layouT_Below="@+id/toolbar"
            tools:context="com.example.sAMMybobo.moglis.MoGLIsmaps"
            />

    </RelativeLayout>


    <LinearLayout
        android:BACkground="#fff"
        android:layout_gravity="bottom"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        >

        <Button
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:onClick="observe"
            android:text="My LOCATIOn"/>

        <Button
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:text="Friends"/>

        <Button
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:text="setTings"/>
    </LinearLayout>

    <android.support.design.widget.FloaTingActionButton
        app:fabSize="mini"
        android:id="@+id/fab"
        android:layout_gravity="bottom|end"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:src="@android:drawable/ic_input_add">

    </android.support.design.widget.FloaTingActionButton>

</android.support.design.widget.CoordinatorLayout>

如果您希望底部线性布局也不与片段重叠,则将其放在相对布局中,并确保片段在线性布局上方.

大佬总结

以上是大佬教程为你收集整理的android – 在coordinatorlayout中重叠视图全部内容,希望文章能够帮你解决android – 在coordinatorlayout中重叠视图所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。