現在我想在每個觸摸事件中更改img1的頂部邊距(每個觸摸事件下降10 px)。下面是我的代碼。我已將此代碼放入我的觸摸事件中活動。更改每個觸摸事件中的佈局邊距
public static int count=0;
int place=-300;
System.out.println("Count is:"+count);
if(count>0)
{
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, place, 0, 0);
ImageView imageView=(ImageView)findViewById(R.id.img1);
// MarginLayoutParams marginLayoutParams=new MarginLayoutParams(imageView.getLayoutParams());
//marginLayoutParams.setMargins(0, 500, 0, 0);
imageView.setLayoutParams(lp);
place=place+10;
}
count++;
現在保證金僅在一次觸摸事件中改變,而不是在每次觸摸事件中改變。
所以我想那個的用戶每一個接觸的形象應該回落了10 PX
thanx這個工作........ –