私はImageViewを持っていて、その余白をプログラムで設定しようとすると、そのsrcはアニメーションリストになっています。RelativeLayout MarginLayoutParams resize ImageView非常に小さくする
ImageView hand = (ImageView)rlRoot.findViewById(R.id.ivHandAnimation);
MarginLayoutParams marginsParams = new MarginLayoutParams(hand.getLayoutParams());
marginsParams.setMargins(this.getLeft(), rlRoot.getMeasuredHeight() - 20, 0, 0);
RelativeLayout.LayoutParams lp = new LayoutParams(marginsParams);
//lp.height = rlRoot.findViewById(R.id.btnHole_14).getMeasuredHeight();
hand.setLayoutParams(lp);
if (hand != null) {
hand.setVisibility(View.VISIBLE);
AnimationDrawable frameAnimation = (AnimationDrawable)hand.getDrawable();
frameAnimation.setCallback(hand);
frameAnimation.setVisible(true, true);
}
lp.heightを設定しようとしましたが、動作しません。また、次のコードでLayoutParamsを作成します。
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
ありがとうございます。
いいえ内部には作成されていませんボタンのクリックイベントにあり、getMeasuredHeightコードは値を返します。 でも、それが幅と高さを変えてはいけません。イメージビューの余白の上限値に設定しました。 –