栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

具有动画的WindowManager(可以吗?)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

具有动画的WindowManager(可以吗?)

我不确定您的任务的确切要求,但是有两种方法可以向窗口提供动画:

  1. 用法

    WindowManager.LayoutParams.windowAnimations
    如下:

    params.windowAnimations = android.R.style.Animation_Translucent;
  2. 添加附加的“容器”视图,因为

    WindowManager
    它不是真实的
    ViewGroup
    ,因此添加视图的普通动画无法使用。已经问过这个问题,但是缺少代码。我将通过以下方式应用它:

    public class BannerLayout extends View {private final Context mContext;private final ViewGroup mPopupLayout;private final ViewGroup mParentView;public BannerLayout(Activity activity, final Context context) {    super(context);    mContext = 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);    final WindowManager mWinManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);    mPopupLayout = (RelativeLayout) inflater.inflate(R.layout.popup_activity, null);    mPopupLayout.setVisibility(GONE);    params.width = ActionBar.LayoutParams.WRAP_CONTENT;    params.height = ActionBar.LayoutParams.WRAP_CONTENT;    // Default variant    // params.windowAnimations = android.R.style.Animation_Translucent;    mParentView = new frameLayout(mContext);    mWinManager.addView(mParentView, params);    mParentView.addView(mPopupLayout);    mPopupLayout.setVisibility(GONE);}public void show(){    final Animation in = AnimationUtils.loadAnimation(this.mContext, android.R.anim.fade_in);    in.setDuration(2000);    mPopupLayout.setVisibility(VISIBLE);    mPopupLayout.startAnimation(in);}public void hide() {    mPopupLayout.setVisibility(GONE);}

    }



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/463456.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号