Comment Définir la taille de l'image dans la vue de grille

J'ai un affichage de la grille avec 3 colonnes enveloppé dans une relative mise en page.
Au moment de la vue sur une grande périphérique (7 pouces tablet) apparaît petit, donc je veux augmenter la taille des images en fonction de la taille de l'écran.

Mon getView() dans baseApdter pour le contrôle Gridview:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AppInfo entry = mListAppInfo.get(position);

        //create a new ImageView and TextView for each item refernced by teh adpter


        if(convertView == null) {

            //if its not recycled, intilise some attributs

            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.layout_appinfo, null);
        }

        //want to change the soze of the image according to screensize then place in the gridview with this apdter


        ImageView ivIcon = (ImageView)convertView.findViewById(R.id.ivIcon);

        //ivIcon.setLayoutParams(new GridView.LayoutParams(
                //(int)mContext.getResources().getDimension(R.dimen.widthImageGridview),
                //(int)mContext.getResources().getDimension(R.dimen.heihgtImageGridview)));
        ivIcon.setLayoutParams(new RelativeLayout.LayoutParams(85, 85));
        ivIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
        ivIcon.setPadding(8, 8, 8, 8);
        ivIcon.setImageBitmap(entry.getIcon());

        TextView tvName = (TextView)convertView.findViewById(R.id.tvName);
        tvName.setText(entry.getName());
        tvName.setTextColor(Color.WHITE);       
        return convertView;
    }

Et mon XML avec affichage de la grille:

<RelativeLayout 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:background="@drawable/background"
    tools:context=".Main" >

        <GridView
        android:id="@+id/gvMain"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:columnWidth="200dip"
        android:gravity="center"
        android:horizontalSpacing="40dip"
        android:numColumns="3"
        android:padding="10dip"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10dip" />

    <Button
        android:id="@+id/btn_facebook"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
android:paddingRight="10dp"
android:paddingBottom="10dp"
        android:background="@drawable/fb_button" />

</RelativeLayout>

Essayez d'utiliser l'imageView.setLayoutparams(...) jette

java.lang.ClassCastException:
android.widget de.RelativeLayout$LayoutParams ne peut pas être lancé à
android.widget de.LinearLayout$LayoutParams

InformationsquelleAutor dancingbush | 2014-04-21