如何将一个ImageView的Y轴上使用动态条件? [英] How to move an ImageView over Y-axis dynamically using conditions.?
问题描述
我有需要移动在y轴动态地根据情况的ImageView的。看到这个图片:
绿点并显示你的文本视图的位置在这个形象必须是上下运动,这取决于用户的下一站(Halasuru图像中)的距离。有没有什么办法,我们可以通过计算总距离的比值的停止和距离之间留有旅行和移动的绿点上下轨道上相应显示它移动图像?
感谢名单提前。
U可以从拉升的绿点图片和down..can有可能通过transulate动画 像
的ImageView ImageView的=(ImageView的)findViewById(R.id.dot_image);
INT X = imageView.getRight() - imageView.getLeft();
INT Y = imageView.getBottom() - imageView.getTop();
TranslateAnimation翻译=新TranslateAnimation(
Animation.ABSOLUTE中,x,Animation.ABSOLUTE,
X,Animation.ABSOLUTE,Y,
Animation.ABSOLUTE,yPosition);
translate.setDuration(150);
translate.setFillEnabled(真正的);
translate.setFillAfter(真正的);
imageView.startAnimation(翻译);
在这里传递yPosition值通过计算之间的总距离 停止和距离离开去旅行,并通过该值
I have an ImageView which needs to be moved over y-axis dynamically depending on the conditions. See this image:
The green dot and the text view showing you are here in this image needs to be moving up and down depending upon the distance of user from the next stop (Halasuru in the image). Is there any way that we can move the image by calculating the ration of total distance between the stops and distance left to travel and show it accordingly by moving the green dot up and down on the track.?
Thanx in Advance.
u can move your green dot image from up and down..can be possible by transulate animation like
ImageView imageView=(ImageView)findViewById(R.id.dot_image);
int x=imageView.getRight()-imageView.getLeft();
int y=imageView.getBottom()-imageView.getTop();
TranslateAnimation translate = new TranslateAnimation(
Animation.ABSOLUTE,x, Animation.ABSOLUTE,
x, Animation.ABSOLUTE,y,
Animation.ABSOLUTE,yPosition);
translate.setDuration(150);
translate.setFillEnabled(true);
translate.setFillAfter(true);
imageView.startAnimation(translate);
here pass yPosition value by calculating total distance between the stops and distance left to travel and pass that value
这篇关于如何将一个ImageView的Y轴上使用动态条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!