我想给我的小工具添加一个按下/触摸的效果。我正在尝试类似这样的东西:
remoteView.setInt(R.id.layout_appwidget_imageButtonPrevious,
"setAlpha", 50);
remoteView.setInt(R.id.layout_appwidget_imageButtonPrevious,
"setAlpha", 255);
单击RemoteView时。问题是,效果会有一定的延迟,因此只有第二个实际显示在小部件中(因此没有可见的触摸效果)。如果我丢弃了第二条指令,我会产生触摸效果,但这是永久性的,这当然是我不想要的。
我该如何解决这个问题?
非常感谢
发布于 2014-07-18 00:53:09
使用动画:
iv = (ImageView) findViewById(R.id.imageView);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Animation animFadein = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.fade_in);
iv.startAnimation(animFadein);
});
在res/anim/fade_in.xml中
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<alpha
android:duration="100"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" />
</set>
https://stackoverflow.com/questions/21970303
复制相似问题