如何放大选定的图像在Android图库 [英] How to zoom selected image in gallery in android
本文介绍了如何放大选定的图像在Android图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序中的画廊。该库我有很多的图像。
谁能告诉我如何放大在Android上的画廊选择的图像?请出示样品code。
I have a gallery in my application. In that gallery I have a lot of images. Can anybody tell me how to zoom in on a selected image in the gallery in android? Please show sample code.
我试着用这个code,但它不工作:
I tried with this code but it's not working:
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent,
View v, int position, long id)
{
if(v!=null)
{
if(position>0){
View previousView=parent.findViewById(position-1);
if(previousView!=null)
{
previousView.setLayoutParams(new Gallery.LayoutParams(100, 120));
}
}
Toast.makeText(getBaseContext(),
"pic" + (position + 1) + " selected",
Toast.LENGTH_SHORT).show();
Animation grow = AnimationUtils.loadAnimation(GalleryActivity.this, R.anim.grow);
v.startAnimation(grow);
v.setLayoutParams(new Gallery.LayoutParams(170, 150));
}
感谢
推荐答案
这code ++工程
gl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{ public void onItemSelected(AdapterView<?> parent, View v, int
position, long id) {
if (lastview != null) lastview .setLayoutParams(new
Gallery.LayoutParams(140, 280)); lastview = v; v.setLayoutParams(new
Gallery.LayoutParams(170, 340)); }
public void onNothingSelected(AdapterView<?> parent) { //
System.out.println("NOTHING SELECTED");
} });
这篇关于如何放大选定的图像在Android图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文