在协调器布局中具有锚点的FAB在android pre-lollipop中具有额外的余量

前端之家收集整理的这篇文章主要介绍了在协调器布局中具有锚点的FAB在android pre-lollipop中具有额外的余量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个CoordinatroLayoutwith FloatingActionButton.这是我的代码
<android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar_layout"
        android:layout_above="@+id/actionbar">

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

            <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="120dp"
                android:minHeight="?android:attr/actionBarSize"
                android:background="@color/toolbar_color" />


            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                >

            </ScrollView>


        </LinearLayout>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:clickable="true"
            app:fabSize="mini"
            android:src="@mipmap/ic_action_edit"
            app:layout_anchor="@id/toolbar"
            app:layout_anchorGravity="bottom|right|end"
            app:backgroundTint="@color/toolbar_color"            />
        </android.support.design.widget.CoordinatorLayout>

但它在棒棒糖和棒棒糖前装置中看起来有所不同.

棒糖:

预棒棒糖:

其实我没有添加任何保证金.但FAB在棒棒糖前设备上有优势.

我在cheessesquare样本中也看到了这个问题.它也显示出不同的边距.问题是什么?

解决方法

我不认为你想放置它们没有边缘.如果我理解正确,你已经这样做了,看看在不同版本的android中发生了什么.

You can use app:useCompatPadding="true" and remove custom margins to maintain same margins across different versions of android

概念证明

原文链接:https://www.f2er.com/android/317164.html

猜你在找的Android相关文章