2017-02-13 5 views
0

Androidスタジオのグリッドビューに画像をフィットする際に問題があります。基本的には、1行につき2枚の画像を必要とし、画像上でTextViewsで下にスクロールすることができますが、上下にスクロールして画像を重ね合わせると位置が変わります。彼らは元の形式で異なる次元を持っています。Android Gridview、画像が一致しない

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="1"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/photo" 
     android:scaleType="fitCenter" 
     android:adjustViewBounds="true" 
     android:layout_margin="2dp"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     android:textSize="10dp" 
     android:id="@+id/hoverText"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:textSize="64dp" 
     android:id="@+id/hoverId"/> 

</RelativeLayout> 

GridViewのレイアウトactivity_district.xml:あなたの助けを

​​

おかげ はここに私の画像レイアウトitem_district.xmlです!

+0

xmlでscaleTypeを変更します。android:scaleType = "fitXy" –

答えて

0

グリッドアイテムの高さはコンテンツに依存しています。つまり、imageviewとurイメージのレンダリングがリサイクルグリッドアイテムビューと同期していないためです。 グリッドアイテムの高さを修正するのが簡単な修正方法です。グリッドアイテムの相対レイアウトに高さを適用します。 最高のUIのために同じサイズのアイテムをgridviewに入れることをお勧めします。

+0

ありがとうございました!完全に働いた:) –

関連する問題