我有一个带卡片视图的片段,当我尝试添加一个导致动画失败的FloatingActionButton时..视图只显示没有动画..宽度和高度和半径都是正确的但是动画选择了# 39;跑。这只是在动画第一次运行时发生..我使用此版本的常规关闭按钮..
CODE
public static void ToogleView(View myView, bool show, Func<int> param = null) {
// get the center for the clipping circle
int cx = myView.Width / 2;
int cy = myView.Height / 2;
// get the final radius for the clipping circle
float finalRadius = (float) Math.Sqrt(cx * cx + cy * cy);
// create the animator for this view (the start radius is zero)
Animator anim;
if (show) {
anim = ViewAnimationUtils.CreateCircularReveal (myView, cx, cy, 0, finalRadius);
} else {
anim = ViewAnimationUtils.CreateCircularReveal (myView, cx, cy, finalRadius, 0);
}
anim.SetDuration (500);
anim.AnimationEnd += (object sender, EventArgs e) => {
if(param != null) {
param();
}
if(!show) {
myView.Visibility = ViewStates.Invisible;
}
};
// make the view visible and start the animation
myView.Visibility = ViewStates.Visible;
anim.Start();
}
XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/mapFragmentRoot"
android:visibility="invisible"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
card_view:cardElevation="4dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="35dp"
android:id="@+id/header"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="30dp"
card_view:cardBackgroundColor="@android:color/white"
card_view:cardCornerRadius="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="0.5"
android:background="@android:color/darker_gray"
android:layout_height="0dp">
<RelativeLayout
android:id="@+id/mapFragmentMapCointatiner"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:layout_height="wrap_content" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="@android:color/white"
android:text="Hämtar närmaste hållplatser"
android:layout_centerInParent="true"
android:paddingTop="60dp"
android:background="@android:color/transparent" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_weight="0.5"
android:layout_width="match_parent"
android:layout_height="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_centerInParent="true"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<!--android.support.design.widget.FloatingActionButton
android:id="@+id/MapFragmentfabClose"
android:elevation="12dp"
card_view:backgroundTint="@android:color/holo_red_dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:src="@drawable/ic_close_white_48dp"
card_view:layout_anchor="@id/header"
card_view:layout_anchorGravity="top|right|end" /-->
</FrameLayout>