2016-06-21 13 views
0

3つのイメージが横に並んだレイアウトがあります。私はのgetParentを試してみましたAndroidイメージのサイズを変更した後にレイアウトのサイズを変更する方法

3 hotdogs not at the top of the screen

何らかの理由で、layout1、2と3の高さについては
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:background="#888888" 
    tools:context="test_layout_resize.MainActivity"> 

    <RelativeLayout 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"/> 

    <RelativeLayout 
     android:id="@+id/layout1" 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"> 
     <ImageView 
      android:id="@+id/image1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/hotdog"/> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"/> 

    <RelativeLayout 
     android:id="@+id/layout2" 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"> 
     <ImageView 
      android:id="@+id/image2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/hotdog"/> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"/> 

    <RelativeLayout 
     android:id="@+id/layout3" 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"> 
     <ImageView 
      android:id="@+id/image3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/hotdog"/> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content"/> 

</LinearLayout> 

は、オリジナルホットドッグの画像ではなく、縮ん1のものである:私はそれらを設定するためにlayout_weight使用しますImageView.onDraw()では.requestLayout()またはinvalidate()のいずれも、何も変更されませんでした。

RelativeLayoutの高さを新しいImageViewの高さに変更するにはどうすればよいですか?

答えて

1

android:adjustViewBounds="true"をすべてImageViewで使用すると、問題が解決します。

希望すると助かります:)

+0

大変ありがとうございます! – pkraau

関連する問題