0

关于如何使厨房视图看起来更好的任何想法?因为它目前不是最好的。任何帮助将不胜感激,它可以是从大小到边框甚至布局的任何内容:)

.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;
}
}
}
4

1 回答 1

0

您可以使用coverflow one 更改整个画廊的形状,如果您愿意,也可以与您的叠加并调整它。

检查此链接:

http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html

希望这有帮助

于 2012-04-21T14:28:33.377 回答