次の問題があります。私のレイアウト xml には、ImageView が配置されている相対的なレイアウトがあります (app /res フォルダーから描画可能で、描画されます)。
最初の場所とまったく同じ場所にプログラムで別の ImageView (アプリ リソースから別のドローアブルを使用) を追加し、その上でアニメーションを実行する必要があります。
私はほぼ成功し、新しいドローアブルと初期ImageViewから取得したレイアウトパラメータを使用して新しいImageViewを追加し、その上でアニメーションを実行しますが、初期ImageView(新しく追加されたものの下にあります)は小さくなっています-理由なしにサイズを変更します(他の子はOKです)。
これを防ぐ方法は?両方の画像の幅と高さがまったく同じで、同じままにする必要があります...よろしくお願いします。
PS 質問を更新します。
> <RelativeLayout> .... ... ... <ImageView deck1 > centerverticaly and
> leftof(other UI component) - this is the initial imageview and
> represents deck full of cards.... ... <ImageView deck2>
> centerverticaly and rightof(other UI component) - this is the second
> deck where the cards should be opened.... ... </RelativeLayout>
今度は、デッキ 1 から 1 枚のカードを取り出し、アニメーションを使用してデッキ 2 に配置する必要があります。だから私は次のことをします:
if(animatingView==null){
ImageView animatingview = new ImageView(this.context);
animatingView.setImageBitmap(R.drawable.backofthecard);
animatinView.setLayoutParams(deck1.getLayoutParams);
RelativeLayout.add(animatingView);
}else{
animatingView.setVisible(visible);
}
animatingView.startAnimation(deckTranslateAnimation);
.
.
..
OnAnimationEnd{animatingView.setVisible(invisible)}
すべてのドローアブルは等しい(幅と高さ)ので、問題はないと思いますが、animatingView がレイアウトに追加されると、deck1 が小さくなり、それ自体のサイズが変更され、クリック可能で表示されますが、小さくなります。 (そして、それに依存する他のすべての子が小さくなるため、それらの場所を変更します...)
申し訳ありませんが、実際のコードと xml を使用していませんが、今はそれらの前にいません...
編集:解決済み。コードは次のとおりです。
if(animatingView==null){
animatingView = new ImageView(context);
animatingView.setImageResource(R.drawable.back);
RelativeLayout.LayoutParams params = new LayoutParams(animatingView.getDrawable().getMinimumWidth(), animatingView.getDrawable().getMinimumHeight());
params.addRule(RelativeLayout.ALIGN_LEFT, this.getDeckView().getCardView().getId());
params.addRule(RelativeLayout.ALIGN_TOP, this.getDeckView().getCardView().getId());
animatingView.setLayoutParams(params);