在Jelly bean(API 18)中,浮动操作按钮未正确对齐,工作正常18及以上

时间:2017-12-19 05:20:08

标签: floating-action-button

我使用浮动操作按钮创建了布局。有一个浮动动作按钮(称为过滤器),我通过它显示另外两个FAB。 问题是关于FAB之间的空间。 API级别18及以下的差距显示更多 布局在API级别19及以上版本中运行良好但在19以下未正确显示,浮动操作按钮之间存在太大差距,不确定此处存在什么问题。如果我需要18岁及以下的空间处理,请告诉我。

Here is Screenshot and xml

enter code here
<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bottom_bar_color"
    android:paddingTop="@dimen/activity_vertical_margin">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/pull_to_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.stylzq.widget.StylzQRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/images_data_list_frag_rv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/go_to_top_fab"
        android:layout_width="52dp"
        android:layout_height="52dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="130dp"
        android:layout_marginRight="15dp"
        android:clickable="false"
        android:src="@drawable/go_to_top"
        android:visibility="gone"
        app:backgroundTint="@color/colorPrimary"
        app:borderWidth="0dp"
        app:elevation="6dp"
        app:layout_anchorGravity="bottom|right"
        app:pressedTranslationZ="12dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="190dp"
        android:gravity="end"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/ll_home_lyt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dimen_6"
            android:visibility="gone">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginRight="10dp"
                android:background="@drawable/fab_text_background"
                android:padding="@dimen/dimen_3"
                android:text="  Home "
                android:textColor="@color/white"
                android:textSize="16sp" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_home_api"
                android:layout_width="52dp"
                android:layout_height="52dp"
                android:layout_marginTop="@dimen/dimen_6"
                android:layout_marginRight="16dp"
                android:src="@drawable/ic_home"
                app:backgroundTint="@color/colorPrimary"
                app:elevation="6dp"
                app:pressedTranslationZ="12dp"
                app:rippleColor="@color/colorPrimaryLight" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/celebs_lyt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dimen_6"
            android:visibility="gone">

            <TextView
                android:id="@+id/celeb_TV"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginRight="10dp"
                android:background="@drawable/fab_text_background"
                android:padding="@dimen/dimen_3"
                android:text=" Celebrity "
                android:textColor="@color/white"
                android:textSize="16sp" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/celebs_api_fab"
                android:layout_width="52dp"
                android:layout_height="52dp"
                android:layout_marginRight="16dp"
                android:src="@drawable/ic_celeb"
                app:backgroundTint="@color/colorPrimary"
                app:elevation="6dp"
                app:pressedTranslationZ="12dp"
                app:rippleColor="@color/colorPrimaryLight" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/popular_lyt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dimen_6"
            android:orientation="horizontal"
            android:visibility="gone">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginRight="10dp"
                android:background="@drawable/fab_text_background"
                android:padding="@dimen/dimen_3"
                android:text="  Popular  "
                android:textColor="@color/white"
                android:textSize="16sp" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/popular_api_fab"
                android:layout_width="52dp"
                android:layout_height="52dp"
                android:layout_marginRight="16dp"
                android:src="@drawable/ic_popular"
                app:backgroundTint="@color/colorPrimary"
                app:elevation="6dp"
                app:pressedTranslationZ="12dp"
                app:rippleColor="@color/colorPrimaryLight" />

        </LinearLayout>
    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/api_filter_fab"
        android:layout_width="52dp"
        android:layout_height="52dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="130dp"
        android:layout_marginRight="16dp"
        android:src="@drawable/ic_filter"
        app:backgroundTint="@color/colorPrimary"
        app:borderWidth="0dp"
        app:elevation="6dp"
        app:layout_anchorGravity="bottom|right"
        app:pressedTranslationZ="12dp"
        app:rippleColor="@color/colorPrimaryLight" />
</RelativeLayout>

0 个答案:

没有答案