Android,View转换bitmap,bitmap转换drawable

摘要:
AndroidView转换Bitmap,Bitmap转换Drawable//测试设置bitmapViewview1=ViewGroup.inflate(context,R.layout.drawable_icon,null);TextViewtextView1=view1.findViewById(R.id.tv_text);TextViewtextView2=view1.findViewById

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

真实可用,以此记录

免责声明:文章转载自《Android,View转换bitmap,bitmap转换drawable》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇忘记root密码,修改方法Redis打造URL缩短服务下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Activity的生命周期详讲及其的生命周期监视,应用程序启动过程,

1:应用程序的启动过程 应用程序的图标被点击-》启动activitythread-》线程的入口main函数-》创建activitythread-》绑定activitythread thread.attach(false,startSeq)-》创建仪表类生命周期,管理程序的生命进程mInstrumentation = new Instrumentation(...

彻底搞懂Spring类加载(注解方式)

单例预加载默认 单例懒加载   正确的加载时机   错误的加载时机 多例懒加载仅支持懒加载 spring beanfactory类高级用法   反射方式加载类 需要注意的问题 通过 Spring 注册的类一共只有三种加载方式! 环境:spring-context 4.2.6jdk 8Eclipse 4.7 最简单的配置 <?xml ve...

警告-SetPropertiesRule Server Service Engine Host Context

在tomcat启动时报错如下错误 问题: 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:o2o’ did not find a matching property. 这...

android: 记录app运行过程中产生的log

有时在解决问题时,经常需要借助logcat才能分析定位问题,这里写了一个小工具,能够记录app运行期间的log, 这样测试人员在反馈bug时,只需要把logcat发给我们就可以了。具体代码如下: import android.content.Context; import android.content.Intent; import android.net...

Java安全之Weblogic内存马

Java安全之Weblogic内存马 0x00 前言 发现网上大部分大部分weblogic工具都是基于RMI绑定实例回显,但这种方式有个弊端,在Weblogic JNDI树里面能将打入的RMI后门查看得一清二楚。并且这种方式实现上传Webshell落地文件容易被Hids监测。 0x01 调试分析 调试分析 写一个filter进行断点跟踪上层代码。 其实和T...

Android 修改TabLayout底部导航条Indicator的长短

关于Tablayout,使用的应该很频繁了,但是底部导航条长短是固定死的,需要自己来改动长短,找了半天没找着方法,看了下官方建议,可以通过映射来修改自己想要的长短,其实也就几行代码的问题,看代码: public static void setIndicator(Context context, TabLayout tabs, int leftDip,...