通过IWindowManager添加的视图动画

时间:2014-05-27 17:17:38

标签: android xamarin.android

如果我通过界面IWindowManager添加一个视图,它将无法正常动画:按钮将保持按下状态,编辑文本将显示其先前的值,即使它们被重写等等。

您是否有办法让视图自行更新?

提前致谢。

[Service()]
public class ExampleService: Service
{
    View mView;
    IWindowManager wm;
    WindowManagerLayoutParams p;
    Handler handler;
    Timer timer;

    public override IBinder OnBind(Intent intent)
    {
        return null;
    }

    public override void OnCreate()
    {
        base.OnCreate();
        this.mView = new View(this);
        this.mView = LayoutInflater.From(this).Inflate(Resource.Layout.Main, null);
        this.mView.LayoutChange += mView_LayoutChange;
        p = new WindowManagerLayoutParams()
        {
            ScreenOrientation = ScreenOrientation.Portrait
        };
        wm = (IWindowManager)GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
        wm.AddView(mView, p);
    }
}

一旦显示通过IWindowManager添加的新视图一切正常,但如果您在其上移动某些内容(单击按钮,写一些文本等),它将不会像正常活动那样更新。我有遗失的财产吗?

1 个答案:

答案 0 :(得分:0)

答案

向WindowManager添加两个视图:一个带有Format = Format.Opaque的黑色视图和你想要的视图Format = Format.Transparent ...