Is there way to make my object look from invisible to visible using ViewPropertyAnimation? I want to move it in a position. While my object is moving to this position i want to increase it's size as original one.
btn.Animate()
.TranslationX(0)
.TranslationY(-250)
.SetDuration(1000)
.SetInterpolator(new OvershootInterpolator(4))
.ScaleXBy(0).ScaleX(1);
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"><android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/button1" />
</RelativeLayout>
My Object is moved in right direction but it's size is remain the same.
You can first set ScaleX(0), and then use ScaleX(1) to set it to increase the size to the original one by some trigger, for example, click a button. So the code is like this:
[Activity(Label = "Animation", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
FloatingActionButton btn;
Button btn2;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
btn = FindViewById<FloatingActionButton>(Resource.Id.button1);
btn2 = FindViewById<Button>(Resource.Id.button2);
btn2.Click += StartAnimate;
btn.Animate().SetDuration(0).ScaleX(0);
}
private void StartAnimate(object sender, EventArgs e)
{
btn.Animate().SetStartDelay(100).TranslationX(0).TranslationY(-250).SetDuration(1000).SetInterpolator(new OvershootInterpolator(4)).ScaleX(1);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.