Gif没有显示在一些Nougat版本上

时间:2018-06-14 12:40:06

标签: android gif angular-ng-if

@SuppressLint("WrongConstant")
private void secondmethod() {

    context = getApplicationContext();

    wm = (WindowManager) getSystemService("window");

    int LAYOUT_FLAG;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
    } else {
        LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_TOAST;
    }

    params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            LAYOUT_FLAG,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |     WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |     WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (!Settings.canDrawOverlays(getBaseContext())) {


            Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
            myIntent.addFlags(FLAG_ACTIVITY_NEW_TASK);
            startActivity(myIntent);
        }

//            frameLayout = new FrameLayout(getBaseContext());
//            frameLayout.setLayoutParams(new FrameLayout.LayoutParams(600, 800));
//            wm.addView(frameLayout, params);
//            frameLayout.setBackgroundResource(R.drawable.gifone);

        giffive = new GifImageView(getBaseContext());
        giffive.setLayoutParams(new FrameLayout.LayoutParams(600, 800));
        wm.addView(giffive, params);
        giffive.setBackgroundResource(R.drawable.giffive);

    }

}

0 个答案:

没有答案