2016-07-07 17 views
0

ホーム画面に合わせるように画像を拡大する際に問題が発生しました。画面サイズに合わせてアイテム画像を調整する

ここにいくつかのスクリーンショットがあります。私はこの

enter image description here

ような何かを達成したい

高さの問題

The height is not as big as it should be

幅問題

Here the height is right but not the width

XML商品コード

<?xml version="1.0" encoding="utf-8"?> 
<com.inthessaloniki.cityguide.view.SelectorRelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/fragment_poi_list_item" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:listSelector="@drawable/selector_clickable_item_bg_inverse"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".MainActivity"> 

     <ImageView 
      android:id="@+id/fragment_poi_list_item_image" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:scaleType="fitXY"/> 

    </RelativeLayout> 

</com.inthessaloniki.cityguide.view.SelectorRelativeLayout> 

私は画像を親の幅と一致させたいがそれに応じてその高さを拡大したい。

答えて

0

scaleType = "fitXY"は画像を強制的にスクリーンに固定し、アスペクト比は保持しません。

は、私は解決策を見つけた最後には、この代わりに

<ImageView 
     android:id="@+id/fragment_poi_list_item_image" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerCrop" 
     android:adjustViewBounds="true"/> 
0

試してみてください。 誰かが同じ問題を抱えている場合に備えてです。

私はそれに応じて画像に合わせるためにscaleYとパディングを使用しました。

<ImageView 
    android:id="@+id/fragment_poi_list_item_image" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="7dp" 
    android:paddingBottom="7dp" 
    android:scaleType="fitXY" 
    android:scaleY="1.25"/> 
関連する問題