2015-06-15 3 views

ответ

8

Сначала добавьте папку в папку «resources», которая называется «anim». , то вы можете добавить свои анимационные ресурсы на него, Ex: для плавного перехода в анимации создать ресурс под папку Anim и назовите его «fade_in.xml» и вставьте этот код в нем:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fillAfter="true" > 

    <alpha 
     android:duration="1000" 
     android:fromAlpha="0.0" 
     android:interpolator="@android:anim/accelerate_interpolator" 
     android:toAlpha="1.0" /> 

</set> 

затем добавить TextView в вашем mainlayout.xml , а также кнопка

<TextView 
      android:text="Text" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/txtMessage" 
      android:layout_marginBottom="35.3dp" /> 

и кнопки:

<Button 
       android:text="fade in" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/fadein" /> 

в "OnCreate" метод в вас активности добавить этот код:

Button fadein = FindViewById<Button>(Resource.Id.fadein); 
      fadein.Click += btn_Click; 

затем добавить этот метод к вашей деятельности:

void blink_Click(object sender, EventArgs e) 
     { 
      txtMessage = FindViewById<TextView>(Resource.Id.txtMessage); 
      Button b = sender as Button; 
      Animation anim = AnimationUtils.LoadAnimation(ApplicationContext, 
          Resource.Animation.fade_in); 
      txtMessage.StartAnimation(anim); 
     }