2017-01-16 17 views
0

「btn_report_addImage1」をクリックすると、写真を撮るためのアプリコールカメラ機能が働きます。ボタンが消え、内側のrelativeLayoutが表示され、表示された画像が表示され、画像の右上に削除ボタンが表示されます。(アンドロイド)背景を設定するとImageViewが大きくなる

問題は次のとおりです。 幅と高さが65dpの画像ビューのサイズを設定しました。 しかし、画像がimageViewに表示されると、画像は以前よりも大きくなります。

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="65dp" 
     android:orientation="horizontal"> 


     <RelativeLayout 
      android:layout_width="65dp" 
      android:layout_height="match_parent"> 
      <Button 
       android:id="@+id/btn_report_addImage1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       /> 
      <RelativeLayout 
       android:id="@+id/layout_report_image1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:visibility="gone" > 

       <ImageView 
        android:id="@+id/image_report_image1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:scaleType="fitXY"/> 
       <Button 
        android:id="@+id/btn_report_removeImage1" 
        android:layout_width="35dp" 
        android:layout_height="25dp" 
        android:layout_alignParentRight="true" 
        android:text="-" 
        android:textSize="5dp" 
        /> 
      </RelativeLayout> 
     </RelativeLayout> 


     <RelativeLayout 
      android:layout_width="65dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp"> 
      <Button 
       android:id="@+id/btn_report_addImage2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
      <RelativeLayout 
       android:id="@+id/layout_report_image2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:visibility="gone"> 

       <ImageView 
        android:id="@+id/image_report_image2" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:scaleType="fitXY"/> 
       <Button 
        android:id="@+id/btn_report_removeImage2" 
        android:layout_width="35dp" 
        android:layout_height="25dp" 
        android:layout_alignParentRight="true"/> 
      </RelativeLayout> 
     </RelativeLayout> 

答えて

0

あなたはfitXYとしてscaleTypeを指定しました。それが理由。

   <ImageView 
       android:id="@+id/image_report_image1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
       // scaleType removed 
0

'

 <ImageView 
     android:id="@+id/image_report_image1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" /> 
0

あなたはImageViewのscaleType「centerCropを設定することができます。私たちはあなたのケースであなたはすでに画像のl*bを定義している、fitXYを呼び出し、そうScaleType = fitXYを削除する軸の両方のビューに合うように画像をスケーリングandroid:scaleType="fitXY"

0

イメージを実際にsrcに追加しようとします。適切な画像サイズを取得し、適切な表示を行うことができます。

関連する問題