0

私は2つのimageViewサイズとrelativelayoutを持っています。両方の画像がプログラムによって読み込まれ、相対レイアウトのサイズを imgBackground のサイズに等しく設定したいと考えています。どうやってやるの?以下を試しましたが、うまくいきませんでした。レイアウトは、imgBackground よりもはるかに大きいように見えます。

imageLayout.getLayoutParams().width = imgBackground.getWidth();
imageLayout.getLayoutParams().height = imgBackground.getHeight();

レイアウトのコードはこちら

<RelativeLayout
     android:id="@+id/imageLayout"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:background="@color/black">
  <ImageView
       android:id="@+id/imgPhoto"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentLeft="true"
       android:layout_alignParentTop="true"
   />

  <ImageView
       android:id="@+id/imgBackground"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
   />
</RelativeLayout>
4

1 に答える 1