如何使这些厨房视图看起来更好?因为它不是目前最好看的。任何帮助都将非常感激,它可以是从大小到边界甚至布局的任何东西:)
.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;
}
}
}
答案 0 :(得分:0)
你可以使用coverflow改变整个Gallery的形状,如果你想要或与你的一起堆叠并调整它。
检查此链接:
http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html
希望这个帮助