Carrousel based on Gallery

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Carrousel based on Gallery

Postby yamaraja » Tue May 19, 2009 9:18 am

Hi,

I try to create a carrousel based on Gallery (selected image bigger than others).
I've read different topics concerning this problem, but it seams that all are base on getScale() function which is no more usable since sdk 0.9.

What i've done so far is to use OnItemSelectedListener.
So in my Activity :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public void onCreate(Bundle icicle) {
  3.  
  4.         super.onCreate(icicle);
  5.  
  6.         setContentView(R.layout.main_screen);
  7.  
  8.         Gallery g =((Gallery) findViewById(R.id.gallery));
  9.  
  10.         g.setAdapter(new MainMenuAdapter(this));
  11.  
  12.         g.setOnItemSelectedListener(this);
  13.  
  14.         g.setCallbackDuringFling(false);
  15.  
  16.     }
  17.  
  18.  
  19.  
  20.     public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
  21.  
  22.         v.setLayoutParams(new Gallery.LayoutParams(150, 150));
  23.  
  24.     }
  25.  
  26.  
  27.  
  28.     public void onNothingSelected(AdapterView<?> arg0) {
  29.  
  30.     }
  31.  
  32.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


And in my adapter :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public View getView(int position, View convertView, ViewGroup parent) {
  3.  
  4.         ImageView i = new ImageView(myContext);
  5.  
  6.         i.setImageResource(myImageIds[position]);
  7.  
  8.         i.setAdjustViewBounds(true);
  9.  
  10.         i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  11.  
  12.         i.setScaleType(ImageView.ScaleType.FIT_XY);
  13.  
  14.         return i;
  15.  
  16.         }
  17.  
  18.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
.

The focused image is well rescaled. But a problem remains : all images are correctly displayed, except the previous focused image which remains scaled :?

If you have any idea !
Regards.
yamaraja
Once Poster
Once Poster
 
Posts: 1
Joined: Wed May 13, 2009 2:51 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 6 guests