2017-01-09 12 views

答えて

0

あなたはtransitionファイルを作成することができます。たとえば、次の

あなたがあなたの活動を開始するコードで
<?xml version="1.0" encoding="utf-8"?> 
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android" 
    android:transitionOrdering="together" 
    android:duration="250"> 
    <slide android:slideEdge="right"> 
     <targets> 
      <target android:targetId="@id/toolbar" /> 
     </targets> 
    </slide> 
</transitionSet> 

そして:

Intent intent = new Intent(this, YourActivityHere.class); 
ActivityOptionsCompat activityOptions = 
     ActivityOptionsCompat.makeSceneTransitionAnimation(this, 
     new Pair<View, String>(viewHolder.mIconView, getString(R.string.detail_icon_transition_name))); 
ActivityCompat.startActivity(this, intent, activityOptions.toBundle()); 
0

右のリンクに左を含む簡単TextViewのアニメーションのための使用、このライブラリを - >Here

enter image description here enter image description here enter image description here

またはプログラムでXから--- ------> X1の単純なアニメーション(負または正の値を変更して元に戻すことができます)

アニメーションフォルダを作成するres(新規>ディレクトリ)> anim

move_it.xml

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

    <translate 
     android:fromXDelta="-3%p" 
     android:toXDelta="30%p" 
     android:duration="1200" /> 
</set> 

し、あなたのコード内で

textView = (TextView) findViewById(R.id.text_one); 
textView.startAnimation(AnimationUtils.loadAnimation(YourActivityName.this, R.anim.move_it)); 
+0

それは言う - 次のクラスは見つかりませんでしたcom.hanks.htextview.Htextview –

+0

@ K.A。シッティキーはあなたがそれをどのように使うのか知っていますか? 1.あなたのgradleに依存関係を追加し、それを同期させます。2.あなたはあなたが望むどんなタイプのアニメーションを与えることができるのか、それらのカスタムXMLを使用することができます!それを使用する方法を示す**用法**の部分を読む、あなたが私のコードの例を使用できる通常のものを必要とする場合、それは魅力のように動作します –

0
リソースXMLを追加

TextSwitcherについては、テキストが変わるたびにアニメーションが発生します。次に、あなたのコード内の

<TextSwitcher 
     android:id="@+id/txtSwitcher" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

TextSwitcher switcher = (TextSwitcher)findViewById(txtSwitcher); 
    switcher.setFactory(new ViewFactory() { 
     @Override 
     public View makeView() { 
      TextView t = new TextView(ActivityClass.this); 
      //do other stuff the suit your needs 
      return t; 
     } 
    }); 

    Animation in = AnimationUtils.loadAnimation(this, 
      android.R.anim.slide_in_left); 
    Animation out = AnimationUtils.loadAnimation(this, 
      android.R.anim.slide_out_right); 

    switcher.setInAnimation(in); 
    switcher.setOutAnimation(out); 

あなたがswitcher.setTextを行う場合( "新しいテキスト")をアニメーションが発生します。