Android图像移动按钮点击
问题描述:
蜂去android编程和学习东西。Android图像移动按钮点击
我有我,我需要什么,下面的代码是当按钮点击发生 第一用户移动只有两个选择的图像将选择两个图像 然后点击链接,他们将移动到左方向
这里我的代码
<ImageView
android:id="@+id/imLady"
android:layout_width="160dp"
android:layout_height="238dp"
android:src="@drawable/lady"
android:layout_marginTop="50dp"/>
<ImageView
android:id="@+id/imLady2"
android:layout_width="160dp"
android:layout_height="238dp"
android:src="@drawable/lady"
android:layout_marginTop="50dp"/>
<ImageView
android:id="@+id/imLady3"
android:layout_width="160dp"
android:layout_height="238dp"
android:src="@drawable/lady"
android:layout_marginTop="50dp"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Move" />
期待的建议,从u解决方案家伙:)问候
答
你需要setAnimations您ImageViews在巴顿0功能
ImageView v1,v2;
Button b;
TranslateAnimation ta1,ta2;
...
public void onCreate(Bundle savedInstances)
{
super.onCreate(savedInstances);
setContentView(R.layout.layoutname);
...
initiate and refer button and imageviews
...
ta1=new TranslateAnimation(fromx,tox,fromy,toy);
ta1.setDuration(1000); //1 second
ta2=new TranslateAnimation(fromx,tox,fromy,toy);
ta2.setDuration(1000); //1 second
b.setOnClickListener(new View.onClickListener(){
@override
public void onClick(View arg0)
{
v1.startAnimation(ta1);
v2.startAnimation(ta2);
}
});
}
指TranslateAnimation文档here
+0
感谢拉詹。我明白了,我知道如何移动图像,但我想要的是第一个用户应该选择两个图像,然后只有按钮clcik应该发生。 – pran 2014-10-28 04:01:19
那么你尝试过这么远吗?你不能指望任何人只是发布你的问题的完整解决方案。本网站仅用于帮助您了解如何自行解决问题或解决您可能遇到的任何错误。 – 2014-10-28 02:23:05
[Moving-the-image-according-to-the-button-click]可能的重复(http://*.com/questions/15849010/moving-the-image-according-to-the-button-click) – Wildroid 2014-10-28 02:34:14
Xaver先生,我的错误,我没有把我的活动代码,并感谢您告诉我告诉这些东西 – pran 2014-10-28 04:07:00