博客
关于我
android获取项目静态资源文件,给activty页面的布局控件进行动态设置背景等等操作
阅读量:83 次
发布时间:2019-02-26

本文共 734 字,大约阅读时间需要 2 分钟。

我的应用场景是获取给整个页面的LinearLayout设置背景,当页面没有数据的时候,就给页面加一个背景图,setBackground()设置页面背景图片:

看代码吧!!!

//获取项目中的静态资源文件        Resources resources = getContext().getResources();//获取项目静态文件下的图片 Drawable drawable = resources.getDrawable(R.drawable.ic_clean_history); //历史图片存量小于0设置图片,大于0设置颜色(判断是否有数据给activty页面的进行动态设置背景)//llHistory 为xml页面的一块布局        if (mSPHistoryImgList != null) {               if (mSPHistoryImgList.size() > 0) {                   llHistory.setBackgroundColor(Color.parseColor("#f4f4f4"));            } else {                   //获取资源目录,没有历史图片的时候加背景图片说明                llHistory.setBackground(drawable);            }        } else {               llHistory.setBackgroundColor(Color.parseColor("#f4f4f4"));        }

交流安卓学习加我微信号:yaxin_com

转载地址:http://ftqu.baihongyu.com/

你可能感兴趣的文章
Nginx+Tomcat实现动静分离
查看>>
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
Nginx/Apache反向代理
查看>>
Nginx: 413 – Request Entity Too Large Error and Solution
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>
Nginx:objs/Makefile:432: recipe for target ‘objs/src/core/ngx_murmurhash.o‘解决方法
查看>>
nginxWebUI runCmd RCE漏洞复现
查看>>
nginx_rtmp
查看>>
Nginx、HAProxy、LVS
查看>>
nginx一些重要配置说明
查看>>
Nginx下配置codeigniter框架方法
查看>>
Nginx与Tengine安装和使用以及配置健康节点检测
查看>>
Nginx中使用expires指令实现配置浏览器缓存
查看>>
Nginx中实现流量控制(限制给定时间内HTTP请求的数量)示例
查看>>