is there way inflate view windowmanager using animation (at android's project)? can't using examples in sites! used many examples none worked!
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); }
i'm not sure exact requirements task, there's 2 ways provide animation window:
use
windowmanager.layoutparams.windowanimationsfollowing:params.windowanimations = android.r.style.animation_translucent;add additonal 'container' view, because
windowmanagernot realviewgroup, normal animation adding views not working it. this question has been asked already, lacks code. apply following way: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); } /** * shows view */ public void show(){ final animation in = animationutils.loadanimation(this.mcontext, android.r.anim.fade_in); in.setduration(2000); mpopuplayout.setvisibility(visible); mpopuplayout.startanimation(in); } /** * hides view */ public void hide() { mpopuplayout.setvisibility(gone); } }
Comments
Post a Comment