CardView的圆角在截图中没有显示出来。

huangapple go评论110阅读模式
英文:

Cardview Rounded Corners are not showing up in Screenshot?

问题

我试图在DialogFragment中的CardView上进行屏幕截图。当我通过代码进行屏幕截图时,顶部的圆角不显示,但底部的圆角正确显示。我在下面的问题中看到了这些问题的提及...

链接:

https://stackoverflow.com/questions/60244119/cardview-loses-its-radius-when-taken-a-screenshot-programmatically

https://stackoverflow.com/questions/53550406/using-pixelcopy-to-copy-a-scaled-view-within-a-dialogfragment

根据上面的问题,我在Fragment类中测试了相同的布局和代码。然后,圆角正确显示...

布局

  1. <!-- 你的布局XML代码 -->

ShotDialog.java

  1. // 你的 ShotDialog.java 代码

BottomDialogFragment.java

  1. // 你的 BottomDialogFragment.java 代码

ShotFragment.java

  1. // 你的 ShotFragment.java 代码

注意:由于您请求只翻译代码部分,我已经移除了代码外的任何额外内容。如果您有任何进一步的问题,请随时问我。

英文:

I'm trying take screenshot of a cardview which is in a DialogFragment. When I take a screenshot via Code. Top rounded corners are not showing but the bottom rounded corners are showing correctly. I saw these issues mentioned in the below Questions...

https://stackoverflow.com/questions/60244119/cardview-loses-its-radius-when-taken-a-screenshot-programmatically

https://stackoverflow.com/questions/53550406/using-pixelcopy-to-copy-a-scaled-view-within-a-dialogfragment

As per the above question, I tested the same layout & code in a Fragment class. Then the rounded corners are showing up correctly...

LAYOUT

  1. &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  2. &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  3. xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  4. xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  5. android:id=&quot;@+id/mainlinear&quot;
  6. android:layout_width=&quot;match_parent&quot;
  7. android:layout_height=&quot;wrap_content&quot;
  8. android:padding=&quot;12dp&quot;
  9. android:layout_margin=&quot;18dp&quot;&gt;
  10. &lt;androidx.cardview.widget.CardView
  11. android:id=&quot;@+id/cardView&quot;
  12. android:layout_width=&quot;wrap_content&quot;
  13. android:layout_height=&quot;wrap_content&quot;
  14. app:cardCornerRadius=&quot;28dp&quot;&gt;
  15. &lt;RelativeLayout
  16. android:layout_width=&quot;wrap_content&quot;
  17. android:layout_height=&quot;wrap_content&quot;
  18. android:background=&quot;@color/colorCand&quot;
  19. android:orientation=&quot;vertical&quot;&gt;
  20. &lt;androidx.appcompat.widget.AppCompatImageView
  21. android:id=&quot;@+id/image&quot;
  22. android:layout_width=&quot;match_parent&quot;
  23. android:layout_height=&quot;320dp&quot;
  24. android:background=&quot;@color/colorWhite&quot;
  25. android:scaleType=&quot;centerCrop&quot;
  26. android:src=&quot;@drawable/turtle&quot; /&gt;
  27. &lt;LinearLayout
  28. android:id=&quot;@+id/header&quot;
  29. android:layout_width=&quot;match_parent&quot;
  30. android:layout_height=&quot;wrap_content&quot;
  31. android:layout_below=&quot;@+id/image&quot;
  32. android:background=&quot;@color/colorAccent&quot;&gt;
  33. &lt;androidx.appcompat.widget.AppCompatImageView
  34. android:id=&quot;@+id/type&quot;
  35. android:layout_width=&quot;48dp&quot;
  36. android:layout_height=&quot;48dp&quot;
  37. android:layout_gravity=&quot;center&quot;
  38. android:layout_marginStart=&quot;8dp&quot;
  39. android:src=&quot;@drawable/ic_idea&quot; /&gt;
  40. &lt;TextView
  41. android:id=&quot;@+id/title&quot;
  42. android:layout_width=&quot;match_parent&quot;
  43. android:layout_height=&quot;wrap_content&quot;
  44. android:layout_gravity=&quot;center_vertical&quot;
  45. android:layout_marginEnd=&quot;8dp&quot;
  46. android:maxLines=&quot;1&quot;
  47. android:textAlignment=&quot;textEnd&quot;
  48. android:textAllCaps=&quot;true&quot;
  49. android:textColor=&quot;@color/colorWhite&quot;
  50. android:textSize=&quot;18sp&quot;
  51. android:textStyle=&quot;bold&quot;
  52. tools:ignore=&quot;RtlCompat&quot;
  53. tools:text=&quot;Sea Turtle Day&quot; /&gt;
  54. &lt;/LinearLayout&gt;
  55. &lt;RelativeLayout
  56. android:id=&quot;@+id/desc&quot;
  57. android:layout_width=&quot;match_parent&quot;
  58. android:layout_height=&quot;wrap_content&quot;
  59. android:layout_below=&quot;@+id/header&quot;
  60. android:background=&quot;@color/colorGray&quot;&gt;
  61. &lt;TextView
  62. android:id=&quot;@+id/tag&quot;
  63. android:layout_width=&quot;match_parent&quot;
  64. android:layout_height=&quot;wrap_content&quot;
  65. android:layout_centerInParent=&quot;true&quot;
  66. android:layout_marginStart=&quot;12dp&quot;
  67. android:layout_marginEnd=&quot;8dp&quot;
  68. android:layout_toStartOf=&quot;@id/category_icon&quot;
  69. android:maxLines=&quot;2&quot;
  70. android:textColor=&quot;@color/colorAccent&quot;
  71. tools:text=&quot;#SeaTurtleDay#SeaTurtleDay&quot; /&gt;
  72. &lt;androidx.appcompat.widget.AppCompatImageView
  73. android:id=&quot;@+id/category_icon&quot;
  74. android:layout_width=&quot;48dp&quot;
  75. android:layout_height=&quot;48dp&quot;
  76. android:layout_alignParentEnd=&quot;true&quot;
  77. android:layout_centerVertical=&quot;true&quot;
  78. android:layout_marginStart=&quot;4dp&quot;
  79. android:layout_marginEnd=&quot;4dp&quot;
  80. android:src=&quot;@drawable/animals&quot; /&gt;
  81. &lt;/RelativeLayout&gt;
  82. &lt;androidx.appcompat.widget.AppCompatImageView
  83. android:id=&quot;@+id/logo&quot;
  84. android:layout_width=&quot;96dp&quot;
  85. android:layout_height=&quot;96dp&quot;
  86. android:layout_below=&quot;@+id/desc&quot;
  87. android:layout_centerHorizontal=&quot;true&quot;
  88. android:layout_gravity=&quot;center&quot;
  89. android:layout_margin=&quot;8dp&quot;
  90. android:src=&quot;@drawable/wwf_logo&quot; /&gt;
  91. &lt;/RelativeLayout&gt;
  92. &lt;/androidx.cardview.widget.CardView&gt;
  93. &lt;/LinearLayout&gt;

ShotDialog.java

  1. public class ShotDialog extends DialogFragment {
  2. StkyrDialogBinding mBind;
  3. private static Context mCon;
  4. private static Boolean viaEntity;
  5. private String mLink;
  6. public ShotDialog() {
  7. }
  8. public static ShotDialognewInstance(Context context, Stkyr mStk, Boolean entityOnclick) {
  9. StkyrDialog frag = new StkyrDialog();
  10. mCon = context;
  11. viaEntity = entityOnclick;
  12. Bundle args = new Bundle();
  13. args.putSerializable(&quot;STK&quot;, mStk);
  14. frag.setArguments(args);
  15. return frag;
  16. }
  17. @Nullable
  18. @Override
  19. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  20. mBind = ShotDialogBinding.inflate(inflater);
  21. getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  22. mBind.fwd.setOnClickListener(view -&gt; {
  23. FragmentManager fm = ((FragmentActivity) mCon).getSupportFragmentManager();
  24. BottomDialogFragment mBot = BottomDialogFragment.newInstance(mCon, mBind.mainlinear);
  25. mBot.show(fm, &quot;ShareDialog&quot;);
  26. });
  27. }
  28. return mBind.getRoot();
  29. }
  30. }

BottomDialogFragment.java (From this Bottomsheet the screenshot code is triggered for the above Dialog)

  1. public class BottomDialogFragment extends BottomSheetDialogFragment {
  2. public static Context mCon;
  3. private static View stkView;
  4. DialogShareBinding mBind;
  5. private String sharePath = &quot;no&quot;;
  6. public static BottomDialogFragment newInstance(Context context, View view) {
  7. mCon = context;
  8. stkView = view;
  9. return new BottomDialogFragment();
  10. }
  11. @Nullable
  12. @Override
  13. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  14. mBind = DialogShareBinding.inflate(inflater);
  15. return mBind.getRoot();
  16. }
  17. @Override
  18. public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
  19. super.onViewCreated(view, savedInstanceState);
  20. mBind.stkShare.setOnClickListener(new View.OnClickListener() {
  21. @Override
  22. public void onClick(View v) {
  23. dismiss();
  24. }
  25. });
  26. mBind.share.setOnClickListener(new View.OnClickListener() {
  27. @Override
  28. public void onClick(View v) {
  29. dismiss();
  30. Log.e(&quot;onClick: &quot;, &quot;SS TRIGGER&quot;);
  31. takeStkShot();
  32. }
  33. });
  34. }
  35. public void takeStkShot() {
  36. if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
  37. ViewImage.Companion.getScreenShotFromView(stkView, getActivity(), (bm) -&gt; {
  38. Log.e(&quot;takeStkShot: &quot;, &quot;&gt; &gt; &gt;&quot;);
  39. storeImage(bm);
  40. return null;
  41. });
  42. } else {
  43. Bitmap bm = ViewImage.Companion.getScreenShot(stkView);
  44. storeImage(bm);
  45. Log.e(&quot;takeStkShot: &quot;, &quot;&gt; &gt; &gt; ScreenShot&quot;);
  46. }
  47. }
  48. private void storeImage(Bitmap bm) {
  49. Log.e(&quot;takeScreenshot: &quot;, &quot;STORING&quot;);
  50. Date now = new Date();
  51. android.text.format.DateFormat.format(&quot;yyyy-MM-dd hh:mm&quot;, now);
  52. try {
  53. // image naming and path to include sd card appending name you choose for file
  54. String mPath = Environment.getExternalStorageDirectory().toString() + &quot;/&quot; + now + &quot;.jpeg&quot;;
  55. try {
  56. Log.d(&quot;ShareImageCreate&quot;, bm.toString());
  57. File imageFile = new File(mPath);
  58. FileOutputStream outputStream = new FileOutputStream(imageFile);
  59. int quality = 100;
  60. bm.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
  61. outputStream.flush();
  62. outputStream.close();
  63. //setting screenshot in imageview
  64. String filePath = imageFile.getPath();
  65. Log.e(&quot;takeScreenshot &gt; &gt; &quot;, filePath);
  66. Bitmap ssbitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
  67. //iv.setImageBitmap(ssbitmap);
  68. sharePath = filePath;
  69. Log.d(&quot;ShareImageCreate&quot;, sharePath);
  70. Toast.makeText(getActivity(),&quot;SCREENSHOT STORED!&quot;,Toast.LENGTH_SHORT).show();
  71. } catch (NullPointerException ex) {
  72. ex.printStackTrace();
  73. }
  74. } catch (Throwable e) {
  75. // Several error may come out with file handling or DOM
  76. e.printStackTrace();
  77. }
  78. }
  79. }

ShotFragment.java (This Gives expected result with rounded corners)

  1. public class ShotFragment extends Fragment {
  2. String mEntityType = Constants.CAUSE;
  3. Bundle mBundle;
  4. ExtendedFloatingActionButton nextFab;
  5. AppCompatImageView img;
  6. CardView mCard;
  7. private String sharePath = &quot;no&quot;;
  8. public View onCreateView(@NonNull LayoutInflater inflater,
  9. ViewGroup container, Bundle savedInstanceState) {
  10. View root = inflater.inflate(R.layout.dialog_test, container, false);
  11. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  12. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true);
  13. ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(&quot;Create Screenshot&quot;);
  14. mCard = root.findViewById(R.id.cardView);
  15. mCard.setOnClickListener(view -&gt; {
  16. takeStkShot();
  17. return root;
  18. }
  19. public void takeStkShot() {
  20. if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
  21. ViewImage.Companion.getScreenShotFromView(mCard, getActivity(), (bm) -&gt; {
  22. Log.e(&quot;takeStkShot: &quot;, &quot;&gt; &gt; &gt;&quot;);
  23. storeImage(bm);
  24. return null;
  25. });
  26. } else {
  27. Bitmap bm = ViewImage.Companion.getScreenShot(mCard);
  28. storeImage(bm);
  29. Log.e(&quot;takeStkShot: &quot;, &quot;&gt; &gt; &gt; ScreenShot&quot;);
  30. }
  31. }
  32. private void storeImage(Bitmap bm) {
  33. Log.e(&quot;takeScreenshot: &quot;, &quot;STORING&quot;);
  34. Date now = new Date();
  35. android.text.format.DateFormat.format(&quot;yyyy-MM-dd hh:mm&quot;, now);
  36. try {
  37. // image naming and path to include sd card appending name you choose for file
  38. String mPath = Environment.getExternalStorageDirectory().toString() + &quot;/&quot; + now + &quot;.jpeg&quot;;
  39. // create bitmap screen capture
  40. //View v1 = lyTakeScreenShots.getRootView();
  41. try {
  42. Log.d(&quot;ShareImageCreate&quot;, bm.toString());
  43. File imageFile = new File(mPath);
  44. FileOutputStream outputStream = new FileOutputStream(imageFile);
  45. int quality = 100;
  46. bm.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
  47. outputStream.flush();
  48. outputStream.close();
  49. //setting screenshot in imageview
  50. String filePath = imageFile.getPath();
  51. Log.e(&quot;takeScreenshot &gt; &gt; &quot;, filePath);
  52. Bitmap ssbitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
  53. //iv.setImageBitmap(ssbitmap);
  54. sharePath = filePath;
  55. Log.d(&quot;ShareImageCreate&quot;, sharePath);
  56. Toast.makeText(getActivity(),&quot;SCREENSHOT STORED!&quot;,Toast.LENGTH_SHORT).show();
  57. } catch (NullPointerException ex) {
  58. ex.printStackTrace();
  59. }
  60. } catch (Throwable e) {
  61. // Several error may come out with file handling or DOM
  62. e.printStackTrace();
  63. }
  64. }

答案1

得分: 5

尝试将以下内容作为替代放入引用项目中的 ViewImage.kt 文件中。主要变更是传递视图的窗口而不是一个 Activity。对话框有自己的窗口,并且不与活动共享窗口。

ViewImage.kt

  1. /**
  2. * 主要代码来自于"Taking Screenshot Programmatically Using PixelCopy Api",作者为 Shivesh Karan Mehta
  3. * 链接:https://medium.com/@shiveshmehta09/taking-screenshot-programmatically-using-pixelcopy-api-83c84643b02a
  4. */
  5. class ViewImage {
  6. companion object {
  7. @JvmStatic
  8. fun getScreenShotFromView(view: View, window: Window, callback: (Bitmap) -> Unit) {
  9. val bitmap: Bitmap
  10. // PixelCopy 可在 API 24 及以上版本中使用,但似乎在 API 29 之前无法百分之百正常工作。
  11. // 可根据 PixelCopy 在您的环境中是否正常工作来调整构建版本语句,直到 "P" 为止。
  12. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
  13. val locationOfView = IntArray(2)
  14. view.getLocationInWindow(locationOfView)
  15. val rect = Rect(locationOfView[0], locationOfView[1],
  16. locationOfView[0] + view.width, locationOfView[1] + view.height)
  17. bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
  18. try {
  19. PixelCopy.request(window, rect, bitmap,
  20. { copyResult: Int ->
  21. if (copyResult == PixelCopy.SUCCESS) {
  22. callback(bitmap)
  23. }
  24. // 可能处理其他结果代码...
  25. },
  26. Handler()
  27. )
  28. } catch (e: IllegalArgumentException) {
  29. // PixelCopy 可能会抛出 IllegalArgumentException,请确保处理它
  30. e.printStackTrace()
  31. }
  32. } else {
  33. bitmap = getScreenShot(view)
  34. callback(bitmap)
  35. }
  36. }
  37. // 该方法将在截取屏幕截图后返回 Bitmap。我们必须传递要截图的视图。
  38. @Suppress("DEPRECATION")
  39. @JvmStatic
  40. fun getScreenShot(view: View): Bitmap {
  41. view.isDrawingCacheEnabled = true
  42. val bitmap = Bitmap.createBitmap(view.drawingCache)
  43. view.isDrawingCacheEnabled = false
  44. return bitmap
  45. }
  46. }
  47. }
英文:

Try the following as a replacement for ViewImage.kt in the referenced project. The main change is to pass in the view's window rather than an Activity. Dialogs have their own windows and don't share a window with activities.

ViewImage.kt

  1. /**
  2. * Bulk of code borrowed from &quot;Taking Screenshot Programmatically Using PixelCopy Api&quot;
  3. * by Shivesh Karan Mehta
  4. * https://medium.com/@shiveshmehta09/taking-screenshot-programmatically-using-pixelcopy-api-83c84643b02a
  5. */
  6. class ViewImage {
  7. companion object {
  8. @JvmStatic
  9. fun getScreenShotFromView(view: View, window: Window, callback: (Bitmap) -&gt; Unit) {
  10. val bitmap: Bitmap
  11. // PixelCopy is available since API 24 but doesn&#39;t seem to work 100% until API 29.
  12. // The build version statement can be adjusted according to how well PixelCopy
  13. // works in your environment before &quot;P&quot;.
  14. if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.P) {
  15. val locationOfView = IntArray(2)
  16. view.getLocationInWindow(locationOfView)
  17. val rect = Rect(locationOfView[0], locationOfView[1],
  18. locationOfView[0] + view.width, locationOfView[1] + view.height)
  19. bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
  20. try {
  21. PixelCopy.request(window, rect, bitmap,
  22. { copyResult: Int -&gt;
  23. if (copyResult == PixelCopy.SUCCESS) {
  24. callback(bitmap)
  25. }
  26. // possible to handle other result codes ...
  27. },
  28. Handler()
  29. )
  30. } catch (e: IllegalArgumentException) {
  31. // PixelCopy may throw IllegalArgumentException, make sure to handle it
  32. e.printStackTrace()
  33. }
  34. } else {
  35. bitmap = getScreenShot(view)
  36. callback(bitmap)
  37. }
  38. }
  39. // Method which will return Bitmap after taking screenshot. We have to pass the view which
  40. // we want to take screenshot.
  41. @Suppress(&quot;DEPRECATION&quot;)
  42. @JvmStatic
  43. fun getScreenShot(view: View): Bitmap {
  44. view.isDrawingCacheEnabled = true
  45. val bitmap = Bitmap.createBitmap(view.drawingCache)
  46. view.isDrawingCacheEnabled = false
  47. return bitmap
  48. }
  49. }
  50. }

答案2

得分: 0

我注意到你正试图从 'mainRelative' 中进行屏幕截图,但在你的 XML 中该项不存在,我认为你应该根据你的需求使用 'cardView' 或 'mainlinear' 的 id。

英文:

I Noticed that you are trying to take a screenshot from 'mainRelative' which does not exist in your xml, I think you should use the id of 'cardView' or 'mainlinear' based on your requirements.

答案3

得分: 0

  1. public class ScreenshotTaker {
  2. private static final String TAG = ScreenshotTaker.class.getSimpleName();
  3. /**
  4. * 对给定的视图进行截图,并将其保存在外部存储中
  5. * @param view 要截图的最外层ViewGroup
  6. * @return 存储中已保存截图的File对象
  7. */
  8. public static File captureScreenshot(View view) {
  9. Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
  10. view.getHeight(), Bitmap.Config.ARGB_8888);
  11. Canvas canvas = new Canvas(bitmap);
  12. view.draw(canvas);
  13. return saveBitmap(view.getContext(), bitmap);
  14. }
  15. public interface ScreenshotFile {
  16. void onComplete(File file);
  17. }
  18. public static void getScreenshotFromView(View view, Window window, ScreenshotFile callback) {
  19. Bitmap bitmap;
  20. // PixelCopy从API 24开始可用,但在API 29之前似乎工作不正常。
  21. // 根据在“P”之前PixelCopy在您的环境中的表现调整构建版本语句。
  22. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
  23. int[] locationOfView = new int[2];
  24. view.getLocationInWindow(locationOfView);
  25. Rect rect = new Rect(locationOfView[0], locationOfView[1],
  26. locationOfView[0] + view.getWidth(), locationOfView[1] + view.getHeight());
  27. bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
  28. try {
  29. PixelCopy.request(window, rect, bitmap, new PixelCopy.OnPixelCopyFinishedListener() {
  30. @Override
  31. public void onPixelCopyFinished(int copyResult) {
  32. if (copyResult == PixelCopy.SUCCESS) {
  33. callback.onComplete(saveBitmap(view.getContext(), bitmap));
  34. }
  35. }
  36. }, new Handler()
  37. );
  38. } catch (Exception ignored) { }
  39. }
  40. }
  41. }
英文:

The Answer given by @Cheticamp is right
Lets Convert it into java

  1. public class ScreenshotTaker {
  2. private static final String TAG = ScreenshotTaker.class.getSimpleName();
  3. /**
  4. * Takes screenshot of given view and saves it in external storage
  5. * @param view outer most ViewGroup that you want a screenshot of
  6. * @return File object of saved screenshot in storage
  7. */
  8. public static File captureScreenshot(View view) {
  9. Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
  10. view.getHeight(), Bitmap.Config.ARGB_8888);
  11. Canvas canvas = new Canvas(bitmap);
  12. view.draw(canvas);
  13. return saveBitmap(view.getContext(),bitmap);
  14. }
  15. public interface screenshotFile{
  16. void onComplete(File file);
  17. }
  18. public static void getScreenShotFromView(View view, Window window, screenshotFile callback ) {
  19. Bitmap bitmap;
  20. // PixelCopy is available since API 24 but doesn&#39;t seem to work 100% until API 29.
  21. // The build version statement can be adjusted according to how well PixelCopy
  22. // works in your environment before &quot;P&quot;.
  23. if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.P) {
  24. int[] locationOfView = new int[2];
  25. view.getLocationInWindow(locationOfView);
  26. Rect rect = new Rect(locationOfView[0], locationOfView[1],
  27. locationOfView[0] + view.getWidth(), locationOfView[1] + view.getHeight());
  28. bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
  29. try {
  30. PixelCopy.request(window, rect, bitmap, new PixelCopy.OnPixelCopyFinishedListener() {
  31. @Override
  32. public void onPixelCopyFinished(int copyResult) {
  33. if (copyResult == PixelCopy.SUCCESS) {
  34. callback.onComplete(saveBitmap(view.getContext(),bitmap));
  35. }
  36. }
  37. }, new Handler()
  38. );
  39. }catch (Exception ignored){ }
  40. }
  41. }
  42. }

huangapple
  • 本文由 发表于 2020年8月17日 18:10:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63448747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定