Android View转换Bitmap,Bitmap转换Drawable

 

  //测试设置bitmap
            View view1 = ViewGroup.inflate(context, R.layout.drawable_icon, null);
            TextView textView1 = view1.findViewById(R.id.tv_text);
            TextView textView2 = view1.findViewById(R.id.tv_text2);
            textView1.setText(data.getName());
            textView2.setText(data.getTradeDate());

            //判断显示那种颜色
            if (data.isNow()){//显示红色
                textView1.setTextColor(context.getResources().getColor(R.color.RED));
                textView2.setTextColor(context.getResources().getColor(R.color.RED));
            }else{//显示黑色
                textView2.setTextColor(context.getResources().getColor(R.color.black));
                textView2.setTextColor(context.getResources().getColor(R.color.black));
            }


            Bitmap bitmap = DateUtil.convertViewToBitmap(view1);
            Drawable drawable=new BitmapDrawable(bitmap);

 

真实可用,以此记录

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-12-10
  • 2022-01-09
  • 2022-12-23
猜你喜欢
  • 2021-06-06
  • 2021-11-03
  • 2021-05-28
  • 2022-02-01
  • 2022-12-23
相关资源
相似解决方案