彈出窗口的動畫我在我的應用程序哈瓦一個彈出窗口,它的出現在某些按鈕點擊 我想動畫淡入設置到這個窗口, 我把XML文件中的「RES /阿尼姆「文件夾並設置彈出窗口的動畫樣式,但動畫不起作用? 這裏是我的代碼:如何使android系統
myanim.xml ...
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="4000"
android:repeatCount="1"/>
</set>
=========================== ====================
創建彈出窗口
private PopupWindow showOptions(Context mcon){
try{
LayoutInflater inflater = (LayoutInflater) mcon.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.options_layout,null);
layout.setAnimation(AnimationUtils.loadAnimation(this, R.anim.myanim));
PopupWindow optionspu = new PopupWindow(layout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
optionspu.setFocusable(true);
optionspu.showAtLocation(layout, Gravity.TOP, 0, 0);
optionspu.update(0, 0, LayoutParams.WRAP_CONTENT, (int)(hei/5));
optionspu.setAnimationStyle(R.anim.myanim);
return optionspu;
}
catch (Exception e){e.printStackTrace();
return null;}
}
=============== ================================== 的onClick方法...(optionsPopup是類型PopupWindow的全局變量)
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.options:
optionsPopup=showOptions(this);
break;
}
這有一定showaslocation方法調用之前設置。但不知何故,當我單擊按鈕時,彈出窗口會多次打開,任何線索爲什麼會多次? – Ari 2016-07-07 16:24:15
@Ari你解決了雙動畫的問題嗎? – Anton 2016-10-19 19:44:50
我設法通過從動畫中移除android:repeatCount =「1」來擺脫雙重動畫 – NewestStackOverflowUser 2016-11-25 23:39:05