我還沒有找到任何有關如何在應用ScaleAnimation後縮放視圖的觸摸區域的解決方案,該動畫確實改變了該視圖的比例,但不是該視圖的觸摸區域。觸摸區域保持不變。下面是我的示例代碼:如何在Android中應用ScaleAnimation後縮放視圖的點擊/觸摸區域?
package com.xyz;
public class XyzActivity extends Activity {
int zoomLevel = 1;
int zoomNext = 2;
Button btn = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AnimationSet set = new AnimationSet(false);
ScaleAnimation anim = new ScaleAnimation(zoomLevel, zoomNext, zoomLevel, zoomNext);
set.addAnimation(anim);
set.setDuration(0);
set.setFillEnabled(true);
set.setFillAfter(true);
v.startAnimation(set);
zoomLevel += zoomNext;
zoomNext = zoomLevel - zoomNext;
zoomLevel-=zoomNext;
}
});
}
}
和Tha XML是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:text="Button" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</RelativeLayout>
什麼我請建議我....
所以你找到了答案,並保持它自己?你應該選擇正確的答案,或在你找到答案後告訴我們;) –
@silviust同意,即時通訊有此問題 – Bish25