DisplayMetrics dm = getResources().getDisplayMetrics(); int scale = dm.densityDpi; if (scale == 240) { // webView.getSettings().setDefaultZo...
分类:
Web程序 时间:
2015-04-17 17:52:51
阅读次数:
207
工作需要使用getIdentifier()方法可以方便的获各应用包下的指定资源ID。主要有两种方法:(1)方式一Resources resources = context.getResources();int indentify = resources.getIdentifier(org.lovea...
分类:
其他好文 时间:
2015-04-16 12:00:47
阅读次数:
126
1.dimens.xml文件: 100dp2.layout.xml中调用//3.activity中调用int margin_top = getResources().getDimension(R.dimen.area_margin_top);ok,没问题,运行正常。注:dimen.xml中area_...
分类:
移动开发 时间:
2015-04-15 13:16:00
阅读次数:
178
位图是我们开发中最常用的资源,毕竟一个漂亮的界面对用户是最有吸引力的。1. 从资源中获取位图可以使用BitmapDrawable或者BitmapFactory来获取资源中的位图。当然,首先需要获取资源: Resources res=getResources();使用BitmapDrawable获取位...
分类:
移动开发 时间:
2015-04-14 12:35:22
阅读次数:
206
Bitmap bmp =BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Paint paint = new Paint(); paint...
分类:
编程语言 时间:
2015-04-13 16:26:01
阅读次数:
639
final?float?height?=?TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,?49,?getResources().getDisplayMetrics()); ?...
分类:
其他好文 时间:
2015-04-13 14:47:21
阅读次数:
108
Locale locale = getResources().getConfiguration().locale;
String language = locale.getLanguage();
其中language为语言码:
zh:汉语
en:英语...
分类:
移动开发 时间:
2015-04-10 15:37:37
阅读次数:
127
(1) 在Android布局文件layout中设置分割线: (2) ListView有好几种风格的分隔线:设置方法: mListView.setDivider(getResources().getDrawable(android.R.drawable.alert_light_frame));关键是....
分类:
移动开发 时间:
2015-04-10 06:29:42
阅读次数:
179
1.资源的访问代码中使用Context的getResources()方法得到Resources对象,访问自己定义的资源R.资源文件类型.资源文件名称,访问系统定义的资源android.R. 资源文件类型.资源文件名称。在其他资源中引用资源一般格式为@[包名称:]资源类型/资源名称android:te...
分类:
移动开发 时间:
2015-04-07 00:32:31
阅读次数:
187
1、字符数组
字符串数组资源由标签定义,在标签中包含的若干标签表示数组元素。
例如
Mercury
Values
Earth
Mars
在代码中引用字符串数组的代码如下:
String[] plans=getResources().getStringArray(R.ar...
分类:
移动开发 时间:
2015-03-14 15:23:49
阅读次数:
239