我有下面的鳕鱼:
Gallery gallery = (Gallery) findViewById(R.id.gallery1);
selectedImage=(ImageView)findViewById(R.id.imageView1);
gallery.setSpacing(1);
gallery.setAdapter(new ImageAdapter(this));
// clicklistener for Gallery
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
// show the selected Image
selectedImage.setImageResource(mImageIds[position]);
// resize the selected Image
}
});
我很困惑如何设置selectedImage的大小,以便它们可以出现在相同大小的xml文件中。请帮助我!!以及如何在xml文件中设置其他图像的大小,以便它也具有相同的大小。谢谢
答案 0 :(得分:0)
使用它:
selectedImage.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0f));
或
selectedImage.setLayoutParams(new LinearLayout.LayoutParams(100dp, 100dp, 0f));