我对 Android 比较陌生。
描述 -
我有一个LinearLayoutwith TextView。我正在TextView动态添加。
当我触摸它时TextView,我想要它ScaleUp,当我TextView再次触摸它时,我想要它ScaleDown。
我的问题是——
- 当一个
TextView是scaled up并且任何其他TextView是touched。旧的TextView应该scale down和新的touchedTextView应该scale up。 - 当我触摸 a 时
scaled upTextView,它TextView应该按比例缩小。
这是我尝试过的
我有 2 组 xml。1 用于放大
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="3.0"
android:toYScale="3.0" >
</scale>
另一个用于缩小
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="3.0"
android:fromYScale="3.0"
android:toXScale="1.0"
android:toYScale="1.0" >
</scale>
我的Activity课——
myTextView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (myTextView.getAnimation() == null) {
Animation a = AnimationUtils.loadAnimation(
getBaseContext(), R.anim.scale_up);
a.setFillAfter(true);
v.startAnimation(a);
} else {
v.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v1,
MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Animation a1 = AnimationUtils
.loadAnimation(
getBaseContext(),
R.anim.scale_down);
a1.setFillAfter(true);
v1.startAnimation(a1);
}
return true;
}
});
}
}
return false;
}
});