• 沒有找到結果。

动画类型 XMLXMLXMLXML 中 JavaCodeJavaCodeJavaCodeJavaCode 中 res/anim/res/anim/res/anim/res/anim/

N/A
N/A
Protected

Academic year: 2022

Share "动画类型 XMLXMLXMLXML 中 JavaCodeJavaCodeJavaCodeJavaCode 中 res/anim/res/anim/res/anim/res/anim/"

Copied!
37
0
0

加載中.... (立即查看全文)

全文

(1)

资源文件夹 资源文件夹 资源文件夹

资源文件夹

1) 引用自定义的资源

android:text="@string/hello"

这里使用"@"前缀引入对一个资源的引用--在@[package:]type/name@[package:]type/name@[package:]type/name

@[package:]type/name

形式 形式 形式

形式

中后面的文本是资源的名称。在这 种情况下,我们不需要指定包名,因为我们引用的是我们自己包中的资源。type是xml子节点名,name是xml属 性 名 :

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="hello">Hello World, HelloDemo!</string>

</resources>

2) 引用系统资源

android:textColor="@android:android:android:

android:

color/opaque_red" 指定package: android 3) 引用主题属性

另外一种资源值允许你引用当前主题中的属性的值。这个属性值只能在样式资源和XML属性中使用;它允许你通过将它 们改变为当前主题提供的标准变化来改变UI元素的外观,而不是提供具体的值。

android:textColor="???

?

android:textDisabledColor"

注意 注意 注意

注意

:::

:

这和资源引用非常类似,除了我们使用一个"?"前缀代替了"@"。当你使用这个标记时,你就提供了属性资源的名称 , 它将会在主题中被查找--因为资源工具知道需要的属性资源,所以你不需要显示声明这个类型(如果声明,其形式就 是?android:attr/android:textDisabledColor)。除了使用这个资源的标识符来查询主题中的值代替原始的资源,其命 名语法和"@"形式一致:?[namespace:]type/name,这里类型可选。

res/anim/

res/anim/

res/anim/

res/anim/

XML XML XML

XML

文件,它们被编译进逐帧动画(

文件,它们被编译进逐帧动画(

文件,它们被编译进逐帧动画(

文件,它们被编译进逐帧动画(

frame frame frame

frame

by by by

by

frame frame frame

frame

animation animation animation

animation

)或补间动画

)或补间动画

)或补间动画

)或补间动画

( ( (

(

tweened tweened tweened

tweened

animation animation animation

animation

) ) )

)

对象对象 对象

对象

动画资源分为两种,一是实现图片的translate、scale、rotate、alpha四种变化。还可以设置动画的播放特性;

另一种是帧动画,逐帧播放设置的资源

路径位于:res/anim/filename.xml,文件名随意

动画类型

Android的animation由四种类型组成

XML XML XML

XML

JavaCode JavaCode JavaCode

JavaCode

alpha 渐变透明度动画效果

scale 渐变尺寸伸缩动画效果

translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果

AlphaAnimation 渐变透明度动画效果 ScaleAnimation 渐变尺寸伸缩动画效果 TranslateAnimation 画面转换位置移动动画效果

(2)

Animation Animation Animation

Animation

主要有两种动画模式

一种是tweened animation(渐变动画)

一种是frame by frame(画面转换动画)

alpha alpha alpha

alpha

xml xml xml

xml

淡出效果 淡出效果 淡出效果

淡出效果

alpha alpha alpha

alpha

xml xml xml

xml

淡入效果 淡入效果 淡入效果

淡入效果

RotateAnimation 画面转移旋转动画效果

XML中 JavaCode

alpha AlphaAnimation

scale ScaleAnimation

XML中 JavaCode

translate TranslateAnimation

rotate RotateAnimation

(3)

rotate.xml rotate.xml rotate.xml

rotate.xml

旋转效果 旋转效果 旋转效果

旋转效果

Scale.xml Scale.xml Scale.xml

Scale.xml

缩放效果 缩放效果 缩放效果

缩放效果

(4)

translate.xml translate.xml translate.xml

translate.xml

移动效果 移动效果 移动效果

移动效果

res/drawable res/drawable res/drawable

res/drawable

png png png

png

.9.png .9.png .9.png

.9.png

.jpg .jpg .jpg

.jpg

文件,它们被编译进以下的 文件,它们被编译进以下的 文件,它们被编译进以下的

文件,它们被编译进以下的

Drawable Drawable Drawable

Drawable

资源子类型中:

资源子类型中:

资源子类型中:

资源子类型中:

要获得这种类型的一个资源,可以使用 要获得这种类型的一个资源,可以使用 要获得这种类型的一个资源,可以使用

要获得这种类型的一个资源,可以使用

Resource.getDrawable(

Resource.getDrawable(

Resource.getDrawable(

Resource.getDrawable(

id id id

id

) ) )

)

位图文件位图文件 位图文件

位图文件

9-patches 9-patches 9-patches

9-patches

(可变尺寸的位图)

(可变尺寸的位图)

(可变尺寸的位图)

(可变尺寸的位图)

为了获取资源类型,使用 为了获取资源类型,使用 为了获取资源类型,使用

为了获取资源类型,使用

mContext.getResources().getDrawable(R.drawable.imageId) mContext.getResources().getDrawable(R.drawable.imageId) mContext.getResources().getDrawable(R.drawable.imageId)

mContext.getResources().getDrawable(R.drawable.imageId)

图片资源一般使用 图片资源一般使用 图片资源一般使用

图片资源一般使用

pngpng png

png

格式,使用其他格式的会出现各种问题,貌似不支持 格式,使用其他格式的会出现各种问题,貌似不支持 格式,使用其他格式的会出现各种问题,貌似不支持

格式,使用其他格式的会出现各种问题,貌似不支持

gifgif gif

gif

格式的图片,可是使用 格式的图片,可是使用 格式的图片,可是使用

格式的图片,可是使用

Movie Movie Movie

Movie

来播放 来播放 来播放

来播放

gifgif gif

gif

格式的图片 格式的图片 格式的图片

格式的图片

路径位于:

路径位于:

路径位于:

路径位于:

res/drawable res/drawable res/drawable

res/drawable

定义格式:可以直接存放图片也可以是 定义格式:可以直接存放图片也可以是 定义格式:可以直接存放图片也可以是

定义格式:可以直接存放图片也可以是

xmlxml xml

xml

等配置文件(一般用于自定义组件)

等配置文件(一般用于自定义组件)

等配置文件(一般用于自定义组件)

等配置文件(一般用于自定义组件)

为了获取资源类型,使用 为了获取资源类型,使用 为了获取资源类型,使用

为了获取资源类型,使用

mContext.getResources().getDrawable(R.drawable.imageId) mContext.getResources().getDrawable(R.drawable.imageId) mContext.getResources().getDrawable(R.drawable.imageId)

mContext.getResources().getDrawable(R.drawable.imageId)

注意:

注意:

注意:

注意:

放在这里的图像资源可能会被aapt工具自动地进行无损压缩优化。比如,一个真彩色但并不需要256色的 PNG可能会被转换为一个带调色板的8位PNG。这使得同等质量的图片占用更少的资源。所以我们得意识到这些放在该 目录下的二进制图像在生成时可能会发生变化。如果你想读取一个图像位流并转换成一个位图(bitmap),请把图像文件放 在res/raw/目录下,这样可以避免被自动优化。

animated-rotate animated-rotate animated-rotate

animated-rotate

Drawable Drawable Drawable

Drawable

animation-list animation-list animation-list

animation-list

Drawable Drawable Drawable

Drawable

帧动画,逐帧播放设置的资源,称为Frame动画

android:oneshot属性代表运行次数,如果为true为只运行一次,false代表运行多次 对应AnimantionDrawable方法中的setOneShot,

android:duration,为显示的时间长度,

对应AnimationDrawable中的addFrame(drawable,duration)方法

(5)

//java代码中动画设置代码 private void animate() {

ImageView view=(ImageView)findViewById(R.id.animationImage);

view.setVisibility(ImageView.VISIBLE);

//将自定义动画文件设置imageview背景

view.setBackgroundResource(R.drawable.frame_animation);

AnimationDrawable frameAnimation=(AnimationDrawable)view.getBackground();

if(frameAnimation.isRunning()) {

frameAnimation.stop();

} Else {

frameAnimation.stop();

frameAnimation.start();

} }

Bitmap Bitmap Bitmap

Bitmap

Drawable Drawable Drawable

Drawable

1.Android 1.Android 1.Android

1.Android

supports supports supports

supports

bitmap bitmap bitmap

bitmap

files files files

files

inin in

in

aa a

a

three three three

three

formats:

formats:

formats:

formats:

.png(preferred), jpg(acceptable), .gif(discouraged)

2.Reference 2.Reference 2.Reference

2.Reference

a a a

a

bitmap bitmap bitmap

bitmap

way:

way:

way:

way:

a.reference a bitmap file directly b.resource ID

c.an alias resource ID in XML

Note:

Note:

Note:

Note:

Bitmap files may be automatically optimized with lossless image compression by the aapt tool.

If you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/ folder instead, where they will not be optimized.

3.file 3.file 3.file

3.file

location:

location:

location:

location:

res/drawable/filename.png (.png, .jpg, or .gif) The filename is used as the resource ID.

4.compiled 4.compiled 4.compiled

4.compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a BitmapDrawable.

5.resource 5.resource 5.resource

5.resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

In XML: @[package:]drawable/filename

6.example:

6.example:

6.example:

6.example:

a.An image saved at res/drawable/myimage.png

b.layout XML applies the image to a View:

<ImageView

android:layout_height="wrap_content"

(6)

android:layout_width="wrap_content"

android:src="@drawable/myimage" />

c.Coding

Resources res = getResources();

Drawable drawable = res.getDrawable(R.drawable.myimage);

Clip Clip Clip

Clip

Drawable Drawable Drawable

Drawable

A drawable defined in XML that clips another drawable based on this Drawable's current Level.

Most often used to implement things like progress bars.

1.file 1.file 1.file

1.file

location:

location:

location:

location:

res/drawable/filename.xml

The filename is used as the resource ID.

2.compiled 2.compiled 2.compiled

2.compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a ClipDrawable.

3.resource 3.resource 3.resource

3.resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

In XML: @[package:]drawable/filename

4.syntax:

4.syntax:

4.syntax:

4.syntax:

<?xml version="1.0" encoding="utf-8"?>

<clip

xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/drawable_resource"

android:clipOrientation=["horizontal" | "vertical"]

android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |

"fill_vertical" | "center_horizontal" | "fill_horizontal" |

"center" | "fill" | "clip_vertical" | "clip_horizontal"] />

5.example:

5.example:

5.example:

5.example:

a.define clip drawable in XML file -> res/drawable/clip.xml

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/android"

android:clipOrientation="horizontal"

android:gravity="left" />

</shape>

b.Apply the clipdrawable to a View in XML layout

<ImageView

android:id="@+id/image"

android:background="@drawable/clip"

android:layout_height="wrap_content"

android:layout_width="wrap_content" />

c.Apply the clipdrawable in Java Code -> progressively reveal the image

ImageView imageview = (ImageView) findViewById(R.id.image);

ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();

drawable.setLevel(drawable.getLevel() + 1000);

(7)

//10,000 present that the image is not clipped and comletely visible

Color Color Color

Color

Drawable Drawable Drawable

Drawable

Inset Inset Inset

Inset

Drawable Drawable Drawable

Drawable

A drawable defined in XML that insets another drawable by a specified distance. This is used when a View needs a background that is smaller than the View's actual bounds.

1.file 1.file 1.file

1.file

location:

location:

location:

location:

res/drawable/filename.xml

The filename is used as the resource ID.

2.compiled 2.compiled 2.compiled

2.compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a InsetDrawable.

3.resource 3.resource 3.resource

3.resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

In XML: @[package:]drawable/filename

4.syntax:

4.syntax:

4.syntax:

4.syntax:

<?xml version="1.0" encoding="utf-8"?>

<inset

xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/drawable_resource"

android:insetTop="dimension"

android:insetRight="dimension"

android:insetBottom="dimension"

android:insetLeft="dimension" />

5.example:

5.example:

5.example:

5.example:

<?xml version="1.0" encoding="utf-8"?>

<inset xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/background"

android:insetTop="10dp"

android:insetLeft="10dp" />

nine-patch nine-patch nine-patch

nine-patch

Drawable Drawable Drawable

Drawable

1.format 1.format 1.format

1.format

A NinePatch is a PNG image in which you can define stretchable regions that Android scales when content within the View exceeds the normal image bounds.

2.Reference 2.Reference 2.Reference

2.Reference

Nine-Patch Nine-Patch Nine-Patch

Nine-Patch

FileFile File

File

a.reference a bitmap file directly b.resource ID

c.an alias resource ID in XML

3.file 3.file 3.file

3.file

location:

location:

location:

location:

res/drawable/filename.9.png

The filename is used as the resource ID.

(8)

4.compiled 4.compiled 4.compiled

4.compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a NinePatchDrawable.

5.resource 5.resource 5.resource

5.resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

In XML: @[package:]drawable/filename

6.example:

6.example:

6.example:

6.example:

a.An image saved at res/drawable/myninepatch.9.png b.Layout XML applies the Nine-Patch to a View:

<Button

android:layout_height="wrap_content"

android:layout_width="wrap_content"

android:background="@drawable/myninepatch" />

7.An7.An 7.An

7.An

alias alias alias

alias

Bitmap Bitmap Bitmap

Bitmap

resource resource resource

resource

filefile file

file

location:

location:

location:

location:

res/drawable/filename.xml

The filename is used as the resource ID.

compiled compiled compiled

compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a NinePatchDrawable.

resource resource resource

resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

In XML: @[package:]drawable/filename

syntax:

syntax:

syntax:

syntax:

<?xml version="1.0" encoding="utf-8"?>

<nine-patch

xmlns:android="http://schemas.android.com/apk/res/android"

android:src="@[package:]drawable/drawable_resource"

android:dither=["true" | "false"] />

example:

example:

example:

example:

<?xml version="1.0" encoding="utf-8"?>

<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"

android:src="@drawable/myninepatch"

android:dither="false" />

Rotate Rotate Rotate

Rotate

Drawable Drawable Drawable

Drawable

Scale Scale Scale

Scale

Drawable Drawable Drawable

Drawable

A drawable defined in XML that changes the size of another drawable based on its current level.

1.file 1.file 1.file

1.file

location:

location:

location:

location:

res/drawable/filename.xml

The filename is used as the resource ID.

2.compiled 2.compiled 2.compiled

2.compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a ScaleDrawable.

3.resource 3.resource 3.resource

3.resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

(9)

In XML: @[package:]drawable/filename

4.syntax:

4.syntax:

4.syntax:

4.syntax:

<?xml version="1.0" encoding="utf-8"?>

<scale

xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/drawable_resource"

android:scaleGravity=["top" | "bottom" | "left" | "right" | "center_vertical" |

"fill_vertical" | "center_horizontal" | "fill_horizontal" |

"center" | "fill" | "clip_vertical" | "clip_horizontal"]

android:scaleHeight="percentage"

android:scaleWidth="percentage" />

5.example:

5.example:

5.example:

5.example:

<?xml version="1.0" encoding="utf-8"?>

<scale xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/logo"

android:scaleGravity="center_vertical|center_horizontal"

android:scaleHeight="80%"

android:scaleWidth="80%" />

Shape Shape Shape

Shape

Drawable Drawable Drawable

Drawable

It is a generic shape defined in XML.

1.file 1.file 1.file

1.file

location:

location:

location:

location:

res/drawable/filename.xml

The filename is used as the resource ID.

2.compiled 2.compiled 2.compiled

2.compiled

resource resource resource

resource

datatype:

datatype:

datatype:

datatype:

Resource pointer to a ShapeDrawable.

3.resource 3.resource 3.resource

3.resource

reference:

reference:

reference:

reference:

In Java: R.drawable.filename

In XML: @[package:]drawable/filename

4.syntax:

4.syntax:

4.syntax:

4.syntax:

<?xml version="1.0" encoding="utf-8"?>

<shape

xmlns:android="http://schemas.android.com/apk/res/android"

android:shape=["rectangle" | "oval" | "line" | "ring"] >

<corners

android:radius="integer"

android:topLeftRadius="integer"

android:topRightRadius="integer"

android:bottomLeftRadius="integer"

android:bottomRightRadius="integer" />

<gradient

android:angle="integer"

android:centerX="integer"

android:centerY="integer"

android:centerColor="integer"

android:endColor="color"

(10)

android:gradientRadius="integer"

android:startColor="color"

android:type=["linear" | "radial" | "sweep"]

android:usesLevel=["true" | "false"] />

<padding

android:left="integer"

android:top="integer"

android:right="integer"

android:bottom="integer" />

<size

android:width="integer"

android:color="color"

android:dashWidth="integer"

android:dashGap="integer" />

<solid

android:color="color" />

<stroke

android:width="integer"

android:color="color"

android:dashWidth="integer"

android:dashGap="integer" />

</shape>

5.example:

5.example:

5.example:

5.example:

在开发程序时为了兼容不同平台不同屏幕,建议各自文件夹根据需求均存放不同版本图片。

我们可以 将已经 做好的 图片放 到该目 录下, 或者通 过自定 义 XML文件来实 现想要 的图片 ,例如 我们可 以定义 shapge_1.xml放到drawable目录下,内容如下:

(11)

Apply this shape drawable to a Button Resources res = getResources();

Drawable shape = res. getDrawable(R.drawable.shapge_1.xml);

Button button = (Button)findViewByID(R.id.button);

button.setBackground(shape);

Selector Selector Selector

Selector

Drawable Drawable Drawable

Drawable

根据状态改变图片显示效果 根据状态改变图片显示效果 根据状态改变图片显示效果

根据状态改变图片显示效果

属性:

属性:

属性:

属性:

android:state_focused

android:state_window_focused android:state_enabled

android:state_checkable android:state_checked android:state_selected android:state_active android:state_single android:state_first android:state_middle android:state_last android:state_pressed

简单示例:

1. 先定义一个名为btnselector.xml文件,代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item

android:state_focused="true"

android:state_pressed="false"

android:drawable="@drawable/focused"/>

<item

android:state_focused="true"

android:state_pressed="true"

android:drawable="@drawable/focusedpressed"/>

<item

android:state_focused="false"

android:state_pressed="true"

android:drawable="@drawable/pressed"/>

<item

(12)

android:drawable="@drawable/default"/>

</selector>

2. ImageButton使用btnselector.xml如下:

<ImageButton

android:id="@+id/stop"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/btnselector"

android:background="#00000000"/>

注意:

注意:

注意:

注意:

android:src(android:background)赋值为"@drawable/btnselector",而不是指向具体的图片资源。

res/layout res/layout res/layout

res/layout

XML文件,被编译成屏幕布局

res/values res/values res/values

res/values

可以被编译成很多种类型的资源的 可以被编译成很多种类型的资源的 可以被编译成很多种类型的资源的

可以被编译成很多种类型的资源的

XML XML XML

XML

文件。

文件。

文件。

文件。

注意 注意 注意

注意

:::

:

不像其他的res/文件夹,它可以保存任意数量的文件,这些文件保存了要创建资源的描述,而不是资源本 身。XML元素类型控制这些资源应该放在R类的什么地方。

尽管这个文件夹里的文件可以任意命名,不过下面使一些比较典型的文件(文件命名的惯例是将元素类型包含在该 名称之中):

array.xml array.xml array.xml

array.xml

定义数组 Colors.xml

Colors.xml Colors.xml

Colors.xml

定义color drawable和颜色的字符串值(color string values)。使 用 Resource.getDrawable() 和Resources.getColor()分别获得这些资源。

dimens.xml dimens.xml dimens.xml

dimens.xml

定义尺寸值(dimension value)。使用Resources.getDimension()获得这些资源。

strings.xml strings.xml strings.xml

strings.xml

定义字符串(string)值。使用Resources.getString()或者Resources.getText()获取这些资 源。getText()会保留在UI字符串上应用的丰富的文本样式。

styles.xml styles.xml styles.xml

styles.xml

定义样式(style)对象

Array Array Array

Array

xml xml xml

xml

字符串数组 字符串数组 字符串数组

字符串数组

(13)

引用方式: R.array.feed_names

整形数组 整形数组 整形数组

整形数组

Color Color Color

Color

xml xml xml

xml

(14)

引用方式引用方式 引用方式

引用方式

: R.clor.white 语法:语法:

语法:

语法:

<color name="color_name">#color_value</color> 可以保存在 res/values/colors.xml (文件名可以任意)。

xml xml xml

xml

引用:

引用:

引用:

引用:

android:textColor="@color/color_name"

JavaJava Java

Java

引用:引用:

引用:

引用:

int color = Resources.getColor(R.color.color_name) 其中#color_value有以下格式(A代表Alpha通道):

#RGB

#ARGB

#RRGGBB

#AARRGGBB

Drawable Drawable Drawable

Drawable

xml xml xml

xml

引用方式引用方式 引用方式

引用方式

:::

:

R.drawable.white

语法:

语法:

语法:

语法:

<drawable name="color_name">color_value</drawable> 可以保存在res/values/colors.xml。

xmlxml xml

xml

引用 引用 引用

引用

android:background="@drawable/color_name"

java java java

java

引用:

引用:

引用:

引用:

Drawable redDrawable = Resources.getDrawable(R.drawable.color_name)

color_name和上面的一样。个人认为,一般情况下使用color属性,当需要用到paintDrawable时才使用drawable属 性。

(15)

Str Str Str

Str

iii

i

ng ng ng

ng

xml xml xml

xml

引用方式 引用方式 引用方式

引用方式

:::

:

R.stirng.hello

Dimension Dimension Dimension

Dimension

xml xml xml

xml

引用方式引用方式 引用方式

引用方式

:::

:

R.dimen.one_pixel

语法:

语法:

语法:

语法:

<dimen name="dimen_name">dimen_value单位</dimen>

一般保存为 一般保存为 一般保存为

一般保存为

res/values/dimen.xml res/values/dimen.xml res/values/dimen.xml

res/values/dimen.xml

。。

度量单位:

px(

px(

px(

px(

象素象素 象素

象素

):

):

):

):

屏幕实际的象素,常说的分辨率1024*768pixels,就是横向1024px, 纵向768px,不同设备显示效果相 同。

in(

in(

in(

in(

英寸英寸 英寸

英寸

):

):

):

):

屏幕的物理尺寸, 每英寸等于2.54厘米。

mm(

mm(

mm(

mm(

毫米毫米 毫米

毫米

):

):

):

):

屏幕的物理尺寸。

pt(

pt(

pt(

pt(

点点

) ) )

)

:::

:

屏幕的物理尺寸。1/72英寸。

dp/dip dp/dip dp/dip

dp/dip

:::

:

与密度无关的象素,一种基于屏幕密度的抽象单位。在每英寸160点的显示器上,1dp = 1px。但dp和px 的比例会随着屏幕密度的变化而改变,不同设备有不同的显示效果。

spsp sp

sp

:::

:

与刻度无关的象素,主要用于字体显示best for textsize,作为和文字相关大小单位.

Style Style Style

Style

xml xml xml

xml

定义样式的文件,分为两种用途:

定义样式的文件,分为两种用途:

定义样式的文件,分为两种用途:

定义样式的文件,分为两种用途:

Style:以一个单位的方式用在布局XML单个元素(控件)当中。 例如:我们可以为TextView定义一种样式风格,包含 文本的字号大小和颜色,然后将其用在TextView特定的实例。

Theme:以一个单位的方式用在应用中所有的Activity当中或者应用中的某个Activity当中。 比如,我们可以定义一个 Theme,它为window frame和panel 的前景和背景定义了一组颜色,并为菜单定义可文字的大小和颜色属性,可以将 这个Theme应用在你程序当中所有的Activity里。

系统 系统 系统

系统

Animation Animation Animation

Animation

style style style

style

public public public

public

static static static

static

final final final

final

intint int

int

Animation Animation Animation

Animation

==

=

=

16973824;

16973824;

16973824;

16973824;

public public public

public

static static static

static

final final final

final

intint int

int

Animation_Activity Animation_Activity Animation_Activity

Animation_Activity

==

=

=

16973825;

16973825;

16973825;

16973825;

public public public

public

static static static

static

final final final

final

intint int

int

Animation_Dialog Animation_Dialog Animation_Dialog

Animation_Dialog

==

=

=

16973826;

16973826;

16973826;

16973826;

(16)

public public public

public

static static static

static

final final final

final

int int int

int

Animation_InputMethod Animation_InputMethod Animation_InputMethod

Animation_InputMethod

=

=

=

=

16973910;

16973910;

16973910;

16973910;

public public public

public

static static static

static

final final final

final

intint int

int

Animation_Toast Animation_Toast Animation_Toast

Animation_Toast

==

=

=

16973828;

16973828;

16973828;

16973828;

public public public

public

static static static

static

final final final

final

intint int

int

Animation_Translucent Animation_Translucent Animation_Translucent

Animation_Translucent

==

=

=

16973827;

16973827;

16973827;

16973827;

系统 系统 系统

系统

MediaButton MediaButton MediaButton

MediaButton

style style style

style

//Media //Media //Media

//Media

Button Button Button

Button

图标 图标 图标

图标

public public public

public

static static static

static

final final final

final

int int int

int

MediaButton MediaButton MediaButton

MediaButton

=

=

=

=

16973879;

16973879;

16973879;

16973879;

public public public

public

static static static

static

final final final

final

int int int

int

MediaButton_Ffwd MediaButton_Ffwd MediaButton_Ffwd

MediaButton_Ffwd

=

=

=

=

16973883;

16973883;

16973883;

16973883;

public public public

public

static static static

static

final final final

final

intint int

int

MediaButton_Next MediaButton_Next MediaButton_Next

MediaButton_Next

==

=

=

16973881;

16973881;

16973881;

16973881;

public public public

public

static static static

static

final final final

final

int int int

int

MediaButton_Pause MediaButton_Pause MediaButton_Pause

MediaButton_Pause

=

=

=

=

16973885;

16973885;

16973885;

16973885;

public public public

public

static static static

static

final final final

final

intint int

int

MediaButton_Play MediaButton_Play MediaButton_Play

MediaButton_Play

==

=

=

16973882;

16973882;

16973882;

16973882;

public public public

public

static static static

static

final final final

final

int int int

int

MediaButton_Previous MediaButton_Previous MediaButton_Previous

MediaButton_Previous

=

=

=

=

16973880;

16973880;

16973880;

16973880;

public public public

public

static static static

static

final final final

final

intint int

int

MediaButton_Rew MediaButton_Rew MediaButton_Rew

MediaButton_Rew

==

=

=

16973884;

16973884;

16973884;

16973884;

系统 系统 系统

系统

TextAppearance TextAppearance TextAppearance

TextAppearance

Style Style Style

Style

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance TextAppearance TextAppearance

TextAppearance

==

=

=

16973886;

16973886;

16973886;

16973886;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_DialogWindowTitle TextAppearance_DialogWindowTitle TextAppearance_DialogWindowTitle

TextAppearance_DialogWindowTitle

=

=

=

=

16973889;

16973889;

16973889;

16973889;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Inverse TextAppearance_Inverse TextAppearance_Inverse

TextAppearance_Inverse

==

=

=

16973887;

16973887;

16973887;

16973887;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Large TextAppearance_Large TextAppearance_Large

TextAppearance_Large

=

=

=

=

16973890;

16973890;

16973890;

16973890;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Large_Inverse TextAppearance_Large_Inverse TextAppearance_Large_Inverse

TextAppearance_Large_Inverse

==

=

=

16973891;I 16973891;I 16973891;I

16973891;I

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Medium TextAppearance_Medium TextAppearance_Medium

TextAppearance_Medium

=

=

=

=

16973892;

16973892;

16973892;

16973892;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Medium_Inverse TextAppearance_Medium_Inverse TextAppearance_Medium_Inverse

TextAppearance_Medium_Inverse

=

=

=

=

16973893;

16973893;

16973893;

16973893;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Small TextAppearance_Small TextAppearance_Small

TextAppearance_Small

==

=

=

16973894;

16973894;

16973894;

16973894;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Small_Inverse TextAppearance_Small_Inverse TextAppearance_Small_Inverse

TextAppearance_Small_Inverse

=

=

=

=

16973895;

16973895;

16973895;

16973895;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Theme TextAppearance_Theme TextAppearance_Theme

TextAppearance_Theme

==

=

=

16973888;

16973888;

16973888;

16973888;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Theme_Dialog TextAppearance_Theme_Dialog TextAppearance_Theme_Dialog

TextAppearance_Theme_Dialog

=

=

=

=

16973896;

16973896;

16973896;

16973896;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget TextAppearance_Widget TextAppearance_Widget

TextAppearance_Widget

==

=

=

16973897;I 16973897;I 16973897;I

16973897;I

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Widget_Button TextAppearance_Widget_Button TextAppearance_Widget_Button

TextAppearance_Widget_Button

=

=

=

=

16973898;I 16973898;I 16973898;I

16973898;I

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget_DropDownHint TextAppearance_Widget_DropDownHint TextAppearance_Widget_DropDownHint

TextAppearance_Widget_DropDownHint

==

=

=

16973904;

16973904;

16973904;

16973904;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget_DropDownItem TextAppearance_Widget_DropDownItem TextAppearance_Widget_DropDownItem

TextAppearance_Widget_DropDownItem

==

=

=

16973905;

16973905;

16973905;

16973905;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget_EditText TextAppearance_Widget_EditText TextAppearance_Widget_EditText

TextAppearance_Widget_EditText

==

=

=

16973900;

16973900;

16973900;

16973900;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget_IconMenu_Item TextAppearance_Widget_IconMenu_Item TextAppearance_Widget_IconMenu_Item

TextAppearance_Widget_IconMenu_Item

==

=

=

16973899;

16973899;

16973899;

16973899;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Widget_TabWidget TextAppearance_Widget_TabWidget TextAppearance_Widget_TabWidget

TextAppearance_Widget_TabWidget

=

=

=

=

16973901;

16973901;

16973901;

16973901;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget_TextView TextAppearance_Widget_TextView TextAppearance_Widget_TextView

TextAppearance_Widget_TextView

==

=

=

16973902;

16973902;

16973902;

16973902;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_Widget_TextView_PopupMenu TextAppearance_Widget_TextView_PopupMenu TextAppearance_Widget_TextView_PopupMenu

TextAppearance_Widget_TextView_PopupMenu

=

=

=

=

16973903;

16973903;

16973903;

16973903;

public public public

public

static static static

static

final final final

final

intint int

int

TextAppearance_Widget_TextView_SpinnerItem TextAppearance_Widget_TextView_SpinnerItem TextAppearance_Widget_TextView_SpinnerItem

TextAppearance_Widget_TextView_SpinnerItem

==

=

=

16973906;

16973906;

16973906;

16973906;

public public public

public

static static static

static

final final final

final

int int int

int

TextAppearance_WindowTitle TextAppearance_WindowTitle TextAppearance_WindowTitle

TextAppearance_WindowTitle

=

=

=

=

16973907;

16973907;

16973907;

16973907;

系统 系统 系统

系统

Theme Theme Theme

Theme

style style style

style

AndroidManifest.xml AndroidManifest.xml AndroidManifest.xml

AndroidManifest.xml

Activity Activity Activity

Activity

声明中加入属性 声明中加入属性 声明中加入属性

声明中加入属性

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

public public public

public

static static static

static

final final final

final

intint int

int

Theme Theme Theme

Theme

==

=

=

16973829;

16973829;

16973829;

16973829;

public public public

public

static static static

static

final final final

final

intint int

int

Theme_Black Theme_Black Theme_Black

Theme_Black

==

=

=

16973832;

16973832;

16973832;

16973832;

public public public

public

static static static

static

final final final

final

intint int

int

Theme_Black_NoTitleBar Theme_Black_NoTitleBar Theme_Black_NoTitleBar

Theme_Black_NoTitleBar

==

=

=

16973833;

16973833;

16973833;

16973833;

參考文獻

相關文件

differential mean value theorem 微分中值定理.

分拆課題為不同部份 通常2至4堂可教完一課 幾乎1至2天要交一次家課 每次家課的題型較少.

學生已在 2000 年版小學數學課程學習單位 4N4「倍數和因數」中認識因

[r]

The 2010/11 Statistical Project Competition (SPC) for Secondary School Students, which is organised by the Hong Kong Statistical Society, co-organised by the

Curriculum planning: Teachers may introduce how to use short division to find the greatest common divisor and the least common multiple of two numbers at Learning Objective 1.4

一個運動場由長方形 PQRS 及兩個半圓組成,如下圖。若長方形 PQRS 的長度 PQ 為 100 m,運動場的周界為 400 m。求長方形 PQRS

一个运动场由长方形 PQRS 及两个半圆组成,如下图。若长方形 PQRS 的长度 PQ 为 100 m,运动场的周界为 400 m。求长方形 PQRS