有没有什么办法使用动画(在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