アニメーション コンテンツを管理するために、RelativeLayout を拡張するカスタム レイアウトを実装しようとしています。アニメーションは TextViews で構成され、ニュースバーのようにスクロールします。これについては、RelativeLayout android:clipChildren="false" で説明しましたが、機能しません: アニメーションはクリップされますか?
アプリケーションの起動後、Web からニュース タイトルのリストをダウンロードし、TextView を作成して、このカスタム レイアウトにプログラムで追加します。TextView のアニメーション化を開始するには、それらの位置と寸法が必要です。そのため、TextView をカスタム レイアウトに追加した後、子 TextView を描画し、寸法を正しく設定して呼び出される関数をオーバーライドする必要があります。onDraw をオーバーライドしようとしましたが、一度しか呼び出されません。
これが私のコードです:
public class NewsAnimationLayout extends RelativeLayout
{
public NewsAnimationLayout(Context context, AttributeSet attrs) {
super(context, attrs);
setWillNotDraw(false);
// TODO Auto-generated constructor stub
}
public NewsAnimationLayout(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
setWillNotDraw(false);
// TODO Auto-generated constructor stub
}
public NewsAnimationLayout(Context context) {
super(context);
setWillNotDraw(false);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//Here I will animate child objects.
}
};
この場合どうすればいいのですか、はっきりさせてもらえますか?
前もって感謝します