缩放图库中选定的图像
我如何缩放图库中选定的图像,我尝试过这个,但效果不太好。 `
public void onItemSelected (AdapterView<?> parent, View v, int position, long id)
{
Animation grow = AnimationUtils.loadAnimation(DetailTvShow.this, R.anim.grow);
Button btn = (Button)findViewById(R.id.button1);
btn.setText("saison "+(position+1));
View sideView = v.findViewById(position + 1);
View sideView1 = v.findViewById(position - 1);
if ((sideView != null)||(sideView1 != null)){
((ImageView)sideView).setLayoutParams(new Gallery.LayoutParams(80, 115));
((ImageView)sideView1).setLayoutParams(new `enter code here`Gallery.LayoutParams(80, 115));
}
/* sideView = parent.findViewById(position + 1);
if (sideView != null)
((ImageView)sideView).setLayoutParams(new Gallery.LayoutParams(80, 115)); */
v.startAnimation(grow);
v.setLayoutParams(new Gallery.LayoutParams(105, 140));
}`
How could i scale the selected image in the Gallery, i tried this, but it doesn't work very well. `
public void onItemSelected (AdapterView<?> parent, View v, int position, long id)
{
Animation grow = AnimationUtils.loadAnimation(DetailTvShow.this, R.anim.grow);
Button btn = (Button)findViewById(R.id.button1);
btn.setText("saison "+(position+1));
View sideView = v.findViewById(position + 1);
View sideView1 = v.findViewById(position - 1);
if ((sideView != null)||(sideView1 != null)){
((ImageView)sideView).setLayoutParams(new Gallery.LayoutParams(80, 115));
((ImageView)sideView1).setLayoutParams(new `enter code here`Gallery.LayoutParams(80, 115));
}
/* sideView = parent.findViewById(position + 1);
if (sideView != null)
((ImageView)sideView).setLayoutParams(new Gallery.LayoutParams(80, 115)); */
v.startAnimation(grow);
v.setLayoutParams(new Gallery.LayoutParams(105, 140));
}`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,有一个与我将在这里介绍的堆栈溢出类似的解决方案,但它无法正常工作,尽管视图会缩放,但它们最终会停止返回到原始大小。
这是我自己发现的修改后的修复程序,到目前为止似乎工作正常并且不会引起任何问题。
在res/anim中创建一个grow.xml文件将缩放尺寸更改为适合您的任何尺寸
复制此类并将其放入继承的图库中或直接放在您的活动中
然后在创建图库类之后附上适配器调用
这对我有用,请告诉我它是否也对您有用。
I had the same issue, there was a similar solution to the one I will present here on stack overflow but it did not work correctly, though the views would scale, they would eventually stop returning to their original size.
Here the modified fix I found for myself that so far seems to work fine and does not cause any issues.
In res/anim create a grow.xml file change to scale sizes to whatever works for you
Copy this class and put it in your inherited gallery or right in your activity
Then after you have created your gallery class and attached the adapter call
This worked for me, let me know if it does for you as well.
也许这会帮助你走上正轨:
}
maybe this will help you to get on the right track:
}