[英]How to edit Widget.Spinner press effect for color change in Android
[英]Press effect Android Widget
我想向小部件添加按動/觸摸效果。 我正在嘗試類似的東西:
remoteView.setInt(R.id.layout_appwidget_imageButtonPrevious,
"setAlpha", 50);
remoteView.setInt(R.id.layout_appwidget_imageButtonPrevious,
"setAlpha", 255);
單擊RemoteView時。 問題在於,效果發生會有一定的延遲,因此小部件中實際上只顯示了第二個(因此沒有可見的觸摸效果)。 如果我放下第二條指令,我會有觸覺效果,但它是永久性的,這當然是我所不希望的。
我該如何解決這個問題?
非常感謝你
帶有動畫:
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.