Comment Augmenter la taille de l'Image Vue dans Android

Je suis en train de travailler sur un projet qui m'oblige à mettre en œuvre deux de défilement horizontale vues avec un d'affichage de l'image entre. Je voudrais étendre la taille de l'affichage de l'image pour remplir l'écart entre le défilement de l'affichage. Je suis allé à travers l'exemple de code, mais il ne semble pas parler de n'importe où dans la taille de l'affichage de l'image. J'ai joint le code ci-dessous après l'Image décrivant mon problème.

Comment Augmenter la taille de l'Image Vue dans Android

public class Gallery2DemoActivity extends Activity {
private Gallery gallery,gallery1;
private ImageView imgView;
private Integer[] Imgid = {
R.drawable.a_1, R.drawable.a_2, R.drawable.a_3, R.drawable.a_4, R.drawable.a_5, R.drawable.a_6, R.drawable.a_7
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gallery = (Gallery) findViewById(R.id.examplegallery);
gallery.setAdapter(new AddImgAdp(this));
gallery1 = (Gallery)findViewById(R.id.examplegallery1);
gallery1.setAdapter(new AddImgAdp(this));
imgView = (ImageView)findViewById(R.id.ImageView01);    
imgView.setImageResource(Imgid[0]);
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
imgView.setImageResource(Imgid[position]); 
}
});
}
public class AddImgAdp extends BaseAdapter {
int GalItemBg;
private Context cont;
public AddImgAdp(Context c) {
cont = c;
TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
GalItemBg =  typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
public int getCount() {
return Imgid.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imgView = new ImageView(cont);
imgView.setImageResource(Imgid[position]);
imgView.setLayoutParams(new Gallery.LayoutParams(110, 100));
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
imgView.setBackgroundResource(GalItemBg);
return imgView;
}
}

C'est mon principal XML fichier.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Gallery
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/examplegallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:layout_weight="1"/>
<Gallery
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/examplegallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>

Ci-dessous est mon Attributs de fichier:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="GalleryTheme">
<attr name="android:galleryItemBackground" />
</declare-styleable>
</resources>
C'est une belle descriptif de l'image qui montre exactement ce que vous voulez. J'aimerais bien voir ça plus souvent. (+1)
merci @Fuzzical Logique... je veux les lecteurs à comprendre mon problème plus facile et la réponse sera mieux aussi 🙂
Publier vos styleable fichiers.
J'ai juste ajouté le Styleable attributs de fichier. Vous pouvez aller à travers elle.

OriginalL'auteur | 2012-01-17