2011-12-17 1 views
0

私は、タッチすると画面の中央に画像が表示されるギャラリーを実装しましたアンドロイドイメージスライドを横から見る

今すぐ画像がポップアップします。どのように私は

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

     <ImageView android:id="@+id/imageView1" android:layout_width="200dip" 
     android:layout_height="200dip" ></ImageView> 
    <Gallery xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/gallery" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="0dip" android:paddingLeft="0dip"/> 
    </LinearLayout> 

アダプターコードスライディング効果、画像の効果があちこちに残されたり、画面の右に来てもらうことができます。

public View getView(int position, View convertView, ViewGroup parent) { 

    ImageView imageView = new ImageView(mContext); 

    imageView.setImageResource(mImageIds[position]); 
    imageView.setLayoutParams(new Gallery.LayoutParams(100, 100)); 
    imageView.setScaleType(ImageView.ScaleType.FIT_XY); 
    imageView.setBackgroundResource(mGalleryItemBackground); 

    return imageView; 
} 

ギャラリーアクティビティ:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.gallery); 

    Gallery gallery = (Gallery) findViewById(R.id.gallery); 
    gallery.setAdapter(new ImageAdaptor(this)); 

    gallery.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView parent, View v, int position, long id) { 
      ImageView image = (ImageView) 
        findViewById(R.id.imageView1); 

      image.setImageResource(mImageIds[position]); 

     } 
    }); 
} 
+0

ギャラリーの作成方法については、いくつかのコードが必要です。 –

+0

が追加されました。ありがとうございます – png

+0

それは左から右に行くので、今、スクロールの動作は何ですか? –

答えて

1

ここにあります私が見つけた解決策

listview.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView parent, View v, int position, 
       long id) { 
      ImageView image = (ImageView) findViewById(R.id.imageView1); 
      Animation exitAnimation; 

      if(position<positionLastCLicked){ 
      exitAnimation = AnimationUtils.loadAnimation(
        GalleryActivity.this, R.layout.image_slidefromleft);} 
      else{ 
       exitAnimation = AnimationUtils.loadAnimation(
         GalleryActivity.this, R.layout.image_slidefromright); 
      } 
      positionLastCLicked = position; 
      image.startAnimation(exitAnimation); 
      Utils.imageLoader.DisplayImage(galleryList.get(position) 
        .getImage(), image); 
     } 

sli defromleft.xml

<?xml version="1.0" encoding="utf-8"?> 
<translate 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:toXDelta="0%" 
    android:fromXDelta="-100%" 
    android:duration="400" 
    android:fillEnabled="true" 
    android:fillAfter="true"> 
</translate> 
関連する問題