通过Android.support.design.circularreveal.cardview.circularrev



我想创建一个像whatsapp的附件功能这样的揭示效果。我四处寻找创建自定义的东西时,我遇到了Android的android.support.design.circularreveal.cardview.CircularRevealCardView视图,而无需添加任何外部库。

我像这样实现了这种观点: -

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.circularreveal.cardview.CircularRevealCardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/ccv_attachment_reveal"
    style="@style/style_mw"
    android:elevation="@dimen/dimen_2dp"
    android:orientation="vertical"
    android:padding="@dimen/dimen_margin_16dp"
    app:cardCornerRadius="@dimen/dimen_8dp"
    >
    <android.support.v7.widget.LinearLayoutCompat
        style="@style/style_mw"
        android:orientation="vertical">
        <RelativeLayout
            android:id="@+id/rl_attachment_first_row"
            style="@style/style_ww"
            android:layout_marginStart="@dimen/dimen_30dp"
            android:layout_marginTop="@dimen/dimen_margin_16dp"
            android:layout_marginEnd="@dimen/dimen_30dp">
            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_add_gallery_image"
                style="@style/style_ww"
                android:layout_alignParentStart="true"
                android:src="@drawable/ic_gallery_image"/>
            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_add_camera_image"
                style="@style/style_ww"
                android:layout_centerHorizontal="true"
                android:src="@drawable/ic_camera"/>
        </RelativeLayout>
        <RelativeLayout
            style="@style/style_ww"
            android:layout_marginStart="@dimen/dimen_30dp"
            android:layout_marginTop="@dimen/dimen_margin_16dp"
            android:layout_marginEnd="@dimen/dimen_30dp"
            android:layout_marginBottom="@dimen/dimen_margin_16dp">
            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_add_gallery_image1"
                style="@style/style_ww"
                android:layout_alignParentStart="true"
                android:src="@drawable/ic_gallery_image"/>
            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_add_camera_image1"
                style="@style/style_ww"
                android:layout_centerHorizontal="true"
                android:src="@drawable/ic_camera"/>
        </RelativeLayout>
    </android.support.v7.widget.LinearLayoutCompat>
</android.support.design.circularreveal.cardview.CircularRevealCardView>

这在我的应用程序上恰当地显示,就像常规卡片视图一样,我可以在按钮点击时将其设置为Visibile/Invissible。但是,但是我找不到任何在线实现方法,显示如何在可见的视图时应用启示动画。是否有内置功能应用动画,或者我必须自己创建一个动画?

请尝试此

int x = layoutContent.getRight();
int y = layoutContent.getBottom();
int startRadius = 0;
int endRadius = (int) Math.hypot(layoutMain.getWidth(), layoutMain.getHeight());
Animator anim = ViewAnimationUtils.createCircularReveal(layoutButtons, x, y, startRadius, endRadius);
layoutButtons.setVisibility(View.VISIBLE);
anim.start();

相关内容

  • 没有找到相关文章

最新更新