Android,View转换bitmap,bitmap转换drawable


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);

 

真实可用,以此记录


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM