9

現在、グレーアウト (黒/白) の背景を持つダイアログを表示する必要があるプロジェクトに取り組んでいます。これを実現するために、アプリ全体のスクリーンショットを撮り、このスクリーンショットをフルスクリーン ダイアログの背景に配置し、ColorFilter を配置してグレー表示にします。

これは初めて完全に機能しますが、下にあるコンテンツをスクロールしてダイアログを再度要求すると、前と同じ背景が表示されます。

私はコードを使用します:

Bitmap bitmap;
View rootView = getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
rootView.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(rootView.getDrawingCache());
rootView.setDrawingCacheEnabled(false);
imageView.setImageBitmap(bitmap);

つまり、getDrawingCache() は常にアプリの同じスクリーンショットを返します。

4

2 に答える 2

0
    RelativeLayout rlThemeOne=findviewbyId(R.id.rlThemeOne);
    rlThemeOne.destroyDrawingCache();   //destroy preview Created cache if any
    rlThemeOne.buildDrawingCache();    //build new cache
    Bitmap bitmap = rlThemeOne.getDrawingCache();  //get the cache in bitmap
于 2021-04-22T14:31:00.917 に答える