0

所以我正在制作一个带有几个浮动操作按钮的应用程序,虽然在我的情况下它们在视图中是固定的,但我喜欢它们的外观

无论如何,对于像果冻豆这样的旧 API,它似乎有问题显示为附加图像,但它是奇巧的,后来它完美地显示出来,任何想法如何解决这个问题?

xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="ly.bsagar.libyanaguid.services">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/fab_margin"
        android:layout_marginRight="@dimen/fab_margin"
        android:layout_weight="1"
        android:gravity="center">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:gravity="center"
            android:text="@string/internetService"
            android:textSize="@dimen/text_size_large" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@drawable/ic_public_black_24dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:layout_marginLeft="@dimen/fab_margin"
        android:layout_marginRight="@dimen/fab_margin"
        android:layout_weight="2"
        android:gravity="center">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="ActInternet"
            android:src="@drawable/ic_done_black_24dp" />

        <android.support.design.widget.FloatingActionButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="DisInternet"
            android:src="@drawable/ic_clear_black_24dp" />

        <android.support.design.widget.FloatingActionButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="getSetting"
            android:src="@drawable/ic_settings_black_24dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/fab_margin"
        android:layout_weight="1"
        android:gravity="center">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:gravity="center"
            android:text="@string/callWaiting"
            android:textSize="@dimen/text_size_large" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@drawable/ic_phone_paused_black_24dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginLeft="@dimen/fab_margin"
        android:layout_marginRight="@dimen/fab_margin"
        android:layout_weight="2"
        android:gravity="center">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="actwaiting"
            android:src="@drawable/ic_done_black_24dp" />

        <android.support.design.widget.FloatingActionButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="deactwaiting"
            android:src="@drawable/ic_clear_black_24dp" />

        <android.support.design.widget.FloatingActionButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="statuswaiting"
            android:src="@drawable/ic_error_outline_black_24dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/fab_margin"
        android:layout_marginRight="@dimen/fab_margin"
        android:layout_weight="1"
        android:gravity="center">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:gravity="center"
            android:text="@string/missedCallNotification"
            android:textSize="@dimen/text_size_medium" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@drawable/ic_phone_missed_black_24dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginLeft="@dimen/fab_margin"
        android:layout_marginRight="@dimen/fab_margin"
        android:layout_weight="2"
        android:gravity="center">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:background="@color/colorAccent"
            android:onClick="actmissed"
            android:src="@drawable/ic_done_black_24dp" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="@dimen/fab_margin"
            android:layout_weight="1"
            android:onClick="deactmissed"
            android:src="@drawable/ic_clear_black_24dp" />

    </LinearLayout>

</LinearLayout>

不好的看法

视野好(忽略那个正方形,我正在测试一些东西

提前致谢

4

1 回答 1

1

好吧,我不知道您面临什么问题,但这可能是该视图的向后兼容性问题。

您可以尝试这个额外的免费浮动操作按钮库,适用于 Android 它有许多自定义项,需要 SDK 版本 9 或更高版本

在此处输入图像描述

完整的演示视频

此外,如果可能降级(如果您使用的是较新版本)build.gradle文件中的 Google 设计库

compile 'com.android.support:design:22.2.0'

您可以在这里找到更多解决方案:

如何使用 AppCompat v21 在 android 中创建浮动操作按钮 (FAB)?

较低版本的浮动操作按钮

希望有帮助

于 2015-12-25T21:28:14.337 回答