2016-10-27 4 views
0

私のカスタムビューには、アニメーションの処理に少し混乱があります。 私が今抱えていることは、このようなクラスです:カスタムビューのアニメーション - アンドロイド

public class ConcreteView extends RelativeLayout { 
     //blah blah code 
     public ConcreteView(Context context, AttributeSet attrs) { 
      //blah blah code 
     } 
     //blah blah code 
} 

と、このようなXML:

<com.package.ConcreteView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#ffffff" 
    android:id="@+id/suggest" 
    app:headerText="This is a custom view. Animations yet to be implemented" 
    app:headertextColor="#212121" 
    app:footerText="Frostbite engine" 
    app:footertextColor="#424242" 
    app:footertextSize="9" 
    app:headerTextFontSize="13"/> 

は、今私は探しているもののすべてを実装する方法でありますこのクラス内の基本的なアニメーション(fadeIn、fadeOut、Slide In/Outなど)は、ConcreteViewのインスタンスを作成してsetAnimationメソッドにアクセスするだけです(プログラムで)。何か案は?カスタムビューの実装インサイド

おかげで、 シャンタヌ

答えて

0

は、あなたは常にthis演算子を使用して、ビューとビュー機能にアクセスすることができます。これを使用すると、アニメーションごとにビューのプロパティを変更できるはずです。

だから、それは

public class ConcreteView extends RelativeLayout { 
     //blah blah code 
     public ConcreteView(Context context, AttributeSet attrs) { 
      //blah blah code 
     } 
     //blah blah code 

     public void blahAnimationFadeOut(){ 
      this.setAlpha(0.5); // dummy example to access all view functions, assuming you can write your own animations programatically 
     } 
} 
+0

おかげでたくさんのようなものになるだろう:) – Han

関連する問題