相关疑难解决方法(0)

如何在两个小部件/布局之间添加新的"浮动操作按钮"

我想你已经看到了新的Android设计指南,新的"浮动动作按钮"又名"FAB"

例如这个粉红色的按钮:

在此输入图像描述

我的问题听起来很愚蠢,我已经尝试了很多东西,但是将这个按钮放在两个布局的交叉点上的最佳方法是什么?

在上面的例子中,这个按钮完全位于我们可以想象的ImageView和relativeLayout之间.

我已经尝试了很多调整,但我确信有一个正确的方法来做到这一点.

android floating-action-button android-coordinatorlayout

282
推荐指数
9
解决办法
32万
查看次数

使用CardView和浮动操作按钮Android创建布局

我想使用Material CardView和Custom Floating Action Button创建类似于以下图像的布局:在此输入图像描述

我开发了这个Layout xml文件,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/mainview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            android:id="@+id/cv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="2dp"
            app:cardElevation="2dp"
            android:layout_marginBottom="@dimen/cardMarginVertical"
            android:layout_marginLeft="@dimen/cardMarginHorizontal"
            android:layout_marginRight="@dimen/cardMarginHorizontal"
            android:layout_marginTop="@dimen/cardMarginVertical"
            app:cardPreventCornerOverlap="false"
            app:contentPadding="0dp">

            <com.github.florent37.materialviewpager.sample.ExpandableTextView
                android:id="@+id/expandingTextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="15dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginBottom="10dp"
                android:text="@string/longText" />

            <RelativeLayout
                android:id="@+id/buttonlayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/expandingTextView"
                android:layout_gravity="bottom"
                android:background="@android:color/transparent">

                <com.getbase.floatingactionbutton.FloatingActionButton
                    android:id="@+id/action_c"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    fab:fab_colorNormal="#fff"
                    android:layout_alignParentRight="true"
                    fab:fab_colorPressed="#fff"
                    android:visibility="visible" />
            </RelativeLayout>
        </android.support.v7.widget.CardView>
    </RelativeLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

android material android-layout material-design

6
推荐指数
1
解决办法
6190
查看次数