有沒有什麼辦法使用動畫(在android的項目)使用WindowManager膨脹視圖?即使使用站點中的示例,我也無法做到!我用了很多例子,但都沒有工作!WindowManager動畫(有可能嗎?)
public BannerLayout(Activity activity, final Context context) {
super(context);
this.context = context;
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.popupLayout = (RelativeLayout) inflater.inflate(R.layout.popup_activity, null);
this.popupLayout.setVisibility(GONE);
this.setActive(false);
wm.addView(this.popupLayout, params);
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private void show(){
Animation in = AnimationUtils.loadAnimation(this.context, android.R.anim.fade_in);
this.popupLayout.setAnimation(in);
this.setActive(true);
this.popupLayout.setVisibility(VISIBLE);
}
sandrstar ...完美地工作!然而......我想知道是否有可能使用這些組件進行動畫翻譯。我需要的效果上下屏幕與此組件... – LeandroPortnoy
私人無效顯示(){ \t \t \t \t //動畫淡入=(動畫)AnimationUtils.loadAnimation(的getContext(),android.R。 anim.fade_in); \t \t //this.startAnimation(fadeIn); \t //this.bannerRelativeLayout.setVisibility(VISIBLE); \t \t \t \t this.setActive(true); mPopupLayout.setVisibility(VISIBLE); \t \t final Animation = in new TranslateAnimation(0,0,-1000,0); in.setDuration(700); AnimationSet animation = new AnimationSet(false); animation.addAnimation(in); \t mPopupLayout.startAnimation(animation); \t} – LeandroPortnoy
對不起。我試過了,似乎它工作正常。可能是你需要使用params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT;爲FrameLayout。 – sandrstar