1

I have a GridView that is showing 2 images on a row. I have an SGS and Galaxy 5 to test the app. Unfortunately, it's not well scaling. I change values attributes in XML to fill the screen of SGS and when i test in Galaxy 5 it's bad, very bad. I don't know what to do. Please try to help me, the GridView is my main layout that launches other activities. XML:

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:columnWidth="90dp"
    android:numColumns="2"
    android:verticalSpacing="20dp"
    android:horizontalSpacing="20dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
    android:background="@drawable/background3"

/>
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
androniennn
  • 3,117
  • 11
  • 50
  • 107

1 Answers1

2

Did you tried android:scaleType="fitXY" ?

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
  • Sorry but have i to delete other attributes in XML ? Like verticalSpacing and horizentalSpacing ? Is there any option to scale the images automatically ? – androniennn Aug 13 '11 at 20:29
  • You can do it in your java code, as well. See the documentation for equivalent methods. – Nikola Despotoski Aug 13 '11 at 20:30
  • imageView.setScaleType(ImageView.ScaleType.FIT_XY ); Yes but i did it via XML. Cleaner ;)! But will it always stretch like this ? I don't want to set the values of the spacing. Can it do it automatically ? – androniennn Aug 13 '11 at 20:33
  • Are you using any adapter? if so, in the getView() you can do so for every image and everytime gridview stack is populated. Experiment removing the spacings, I cannot imagine right know how it would look like if there is no spacing :D – Nikola Despotoski Aug 13 '11 at 20:39
  • Exactly, there is setLayoutParams or setPadding, i can set them to the right values when i have the Galaxy 5, but when i apply the app in the SGS, i have a very bad display. How can i get rid of this problem ? – androniennn Aug 13 '11 at 20:45
  • Try not using fixed number of values (px/dpi/sp) for your views. Its really bad habit and practice :D If it works for one then might not work of other display. – Nikola Despotoski Aug 13 '11 at 20:48
  • Exactlyy, what can i use so ? In GridView as i know i have to adjust numbers for it horizental,vertical spacing... – androniennn Aug 13 '11 at 20:51
  • Try stretching the image and increase the divider between the gridlines of the gridview. That will give effect of spacing between the images – Nikola Despotoski Aug 14 '11 at 00:27
  • I have this line in XML and it's not doing something effective: android:stretchMode="columnWidth" . And for the spacing i have it now on 50 and 50 for Horizantal and Vertical. Always the problem of scaling is present. Best with SGS worst on Galaxy 5.... – androniennn Aug 14 '11 at 01:13