標簽:resources res show out resource make ddr XML 布局文件
(可直接通過R類調用),assets文件夾中的資源,如mp3必須通過二進制流來讀取
<TextView android:id="@+id/textView" android:textColor="@color/gray81" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" />
2.在activity中
int gray91 = this.getResources().getColor(R.color.gray91); //通過getResources對象獲取資源,(string資源context.getString()即可獲得) Toast.makeText(this,""+gray91,Toast.LENGTH_LONG).show(); this.getWindow().setBackgroundDrawableResource(R.color.gray91); //通過getWindows對象獲取資源
px 像素 屏幕真實像素
in 英寸 屬于屏幕的物理英寸
pd 與密度無關的像素 相對屏幕物理密度的抽象單位
sp 與精度無關的像素 同上
mm 可以直接引用物理單位(支持小數)(實測cm不能用)
只能在java中調用,不能在xml中調用
標簽:resources res show out resource make ddr XML 布局文件
原文地址:http://www.cnblogs.com/cenzhongman/p/5986224.html