码迷,mamicode.com
首页 >  
搜索关键字:getresources    ( 268个结果
dpi dp px 换算关系
getResources().getDisplayMetrics().densityDpi 就是屏幕密度。getResources().getDisplayMetrics().density 也可以理解为1dip相当于多少个px啦。 dpi是240,1dip=1.5px 标准dpi = 160 ld ...
分类:其他好文   时间:2017-10-17 17:29:24    阅读次数:435
更改控件中DrawableLeft图片的大小,图片与文字的距离
Drawable drawable=getResources().getDrawable(R.drawable.xx); //获取图片 drawable.setBounds(left, top, right, bottom); //设置图片参数 xx.setCompoundDrawablesRela ...
分类:其他好文   时间:2017-08-31 21:05:02    阅读次数:212
Android适配方案小结(二)
该节主要记录从代码中获取与屏幕适配相关的各个參数: Java代码例如以下public class ScreenUtil { /** * Note: * 仅仅有activity能够使用getWindowManager。否则应该使用 * Context.getResources().getDisplay ...
分类:移动开发   时间:2017-07-31 11:21:30    阅读次数:154
android 通过bitmapfactory得到图片真实像素的方法,以及没有得到真实像素的原因
原文来自:原文地址 由于这个错误导致浪费非常长时间找原因,所以要赶紧记录下来。 过程是这种,在使用android读取图片的时候,就是使用BitmapFactory.decodeResource(this.getResources(),R.drawable.base)的时候 返回的图片大小和真实图片大 ...
分类:移动开发   时间:2017-07-18 00:12:14    阅读次数:179
为ImageView设置背景图片(代码中)
仅仅需三行代码: Resources resources = getBaseContext().getResources(); Drawable imageDrawable = resources.getDrawable(R.drawable.background_image); //图片在draw ...
分类:其他好文   时间:2017-06-26 21:15:43    阅读次数:139
一分钟了解Android横竖屏 mdpi hdpi xhdpi xxhdpi xxxhdpi
DPI:每英寸像素数 简单的屏幕分辨率计算方法: DisplayMetrics metrics = this.getResources().getDisplayMetrics(); float density = metrics.density; int dpi = metrics.densityD ...
分类:移动开发   时间:2017-06-22 10:08:36    阅读次数:279
Android 获取虚拟按键的高度
//获取虚拟按键的高度 public static int getNavigationBarHeight(Context context) { int result = 0; if (hasNavBar(context)) { Resources res = context.getResources ...
分类:移动开发   时间:2017-05-25 19:44:19    阅读次数:382
赵雅智_Android的getResources()资源引用
今天做一个Android的刮刮乐项目。里面用到非常多的地方用到了getResources。 <span style="font-size:12px;"> // 获得图片 //參数1:res是资源的引用,參数2:id是图片的id after = BitmapFactory.decodeResource ...
分类:移动开发   时间:2017-05-19 23:56:00    阅读次数:258
沉浸式
1.在项目中加入compile 'com.jaeger.statusbaruitl:library:1.2.7' 调用 StatusBarUtil.setColorNoTranslucent(curActivity,getResources().getColor(R.color.colorPrima ...
分类:其他好文   时间:2017-05-04 20:10:12    阅读次数:243
自己定义Actionbar
自己定义Actionbar有两种方式:代码方式和xml方式 先说代码方式: //getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ad_action_bar_gradient_bak)) ...
分类:其他好文   时间:2017-04-18 11:28:45    阅读次数:202
268条   上一页 1 2 3 4 5 ... 27 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!