Skip to content Skip to sidebar Skip to footer

Anchor An Floating Button On A Cardview

I try to anchor an floating button on a cardview without success. Copy

Solution 2:

Before posting a question doa bit a googling, on the second result was this answer

EDIT

I implemented this in a separate project and it works fine...

<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><android.support.v4.widget.NestedScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"
    ><android.support.v7.widget.CardViewandroid:id="@+id/cv"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="16dp"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level. This design means that your applications can use the libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up." /></android.support.v7.widget.CardView></android.support.v4.widget.NestedScrollView><android.support.design.widget.FloatingActionButtonandroid:layout_height="wrap_content"android:layout_width="wrap_content"app:layout_anchor="@id/cv"app:layout_anchorGravity="right|end|bottom"android:layout_marginRight="32dp"android:clickable="true"/></android.support.design.widget.CoordinatorLayout>

Solution 3:

Wrap the entire layout in a CoordinatorLayout and define your anchor to the card view.

app:layout_anchor="@id/card_view"app:layout_anchorGravity="bottom|end|right"

Then it should work.

Post a Comment for "Anchor An Floating Button On A Cardview"