2012-04-21 23 views
0

任何想法如何使這個廚房視圖看起來更好?因爲它目前看起來並不是最好的。任何幫助,將不勝感激,它可以從大小到邊界,甚至佈局:)是什麼使Android畫廊視圖看起來更好

的.XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <Gallery android:id="@+id/gallery1" android:layout_width="fill_parent" 
      android:layout_height="wrap_content"></Gallery> 
    <ImageView android:id="@+id/ImageView01" 
      android:layout_gravity="center_vertical|center_horizontal" 
      android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> 
</LinearLayout> 

我的活動:

package kevin.erica.box; 
import android.app.Activity; 
import android.content.Context; 
import android.content.res.TypedArray; 
import android.os.Bundle; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.AdapterView; 
import android.widget.AdapterView.OnItemClickListener; 
import android.widget.BaseAdapter; 
import android.widget.Gallery; 
import android.widget.ImageView; 
public class App2Activity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.gallery); 
    Gallery g = (Gallery) findViewById(R.id.gallery1); 
    g.setAdapter(new ImageAdapter(this)); 
    g.setOnItemClickListener(new OnItemClickListener() { 


     public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View v, int position, long id) { 
      ImageView imageview = (ImageView) findViewById(R.id.ImageView01); 
      imageview.setImageResource(mImageIds[position]); 


     } 
    }); 
} 

public Integer[] mImageIds = { 
     R.drawable.lemon, 
     R.drawable.kevin, 
     R.drawable.mirror 
}; 
public class ImageAdapter extends BaseAdapter { 
int mGalleryItemBackground; 
private Context mContext; 

public ImageAdapter(Context c) { 
    mContext = c; 
    TypedArray a = obtainStyledAttributes(R.styleable.HelloGallery); 
    mGalleryItemBackground = a.getResourceId(
      R.styleable.HelloGallery_android_galleryItemBackground, 0); 
    a.recycle(); 
} 
public int getCount() { 
    return mImageIds.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 i = new ImageView(mContext); 
    i.setImageResource(mImageIds[position]); 
    i.setLayoutParams(new Gallery.LayoutParams(150, 100)); 
    i.setScaleType(ImageView.ScaleType.FIT_XY); 
    i.setBackgroundResource(mGalleryItemBackground); 
    return i; 
} 
} 
} 

回答