我想创建一个像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>
这在我的应用程序上像常规的CardView一样正常显示,并且可以通过单击按钮将其设置为可见/不可见。但是,我找不到任何在线实现可以显示此视图的同时应用揭示动画的实现。有内置的功能可以应用动画吗?还是我必须自己创建一个动画?
答案 0 :(得分:0)
请尝试这个
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();