1.设置窗口的背景:getWindow().setBackgroundDrawableResource(R.drawable.back);
2.设置窗体的标题:getWindow().setText(getResources().getText(R.string.main_title));
3.<?xml version="1.0" encoding="utf-8">
<resources>
<color name="red">#ffff0000</color>
<string name="hello">hello</string>
<dimen name="spacing">8dip</dimen>
<bool name="is_true">true</bool>
<integer name="book_number">12</integer>
</resources>
android:textColor="@color/red"
android:text="@string/hello"
android:textSize="@dimen/spacing"
text.setWidth((int)getResources().getDimension(R.dimen.spacing));
boolean is_true=getResources().getBoolean(R.bool.is_true);
int book_number=getResources().getInteger(R.integer.book_number);
4.数组资源:
<!--普通类型的数组 例如Drawable数组 TypedArray obtainTypedArray(int id) 根据普通数组资源的名称来获取普通数组-->
<array name="plain_arr">
<item>@color/c1</item>
</array>
<!--字符串数组 通过 String[]getStringArray(int id) 获取字符串数组-->
<string-array name="string_arr">
<item>@string/c1</item>
<item>谢丹替补</item>
</string-array>
<!--整形数组 通过 int[]getIntegerArray(int id)获取实际的整形数组-->
<integer-array name="book-num">
<item>1</item>
</integer-array>
typedArray icons=getResources().obtainTypedArray(R.array.plain_arr);
text.setBackgroundDrawable(icons.getDrawable(position));
5 Drawable资源
5.1 StateListDrawable
<?xml version="1.0" encoding="utf-8">
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color/drawable="***" android:state_pressed="true|false"/>
</selector>
5.2 LayerDrawable
<?xml version="1.0" encoding="utf-8">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/grow"></item>
<item android:id="@android:id/background" android:drawable="@drawable/progress"></item>
<layer-list>
5.3 ShapeDrawable
<?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(半径)=""
android:topLeftRadius=""/>
<!--定义使用渐变色填充-->
<gradient android:angle(坡度)="integer"
android:centerX|centerY="integer"
android:centerColor="color"
android:startColor="color"
android:endColor="color"
android:gradientRadius="integer"
android:type="linear(线性)|radial(放射状)|sweep(曲线)"
android:userLevel="true|false"/>
<!--定义几何形状的内边距-->
<padding android:left|top|right|bottom=""/>
<!--定义几何形状的大小-->
<size android:width="integer"
android:color="color"
android:dashWidth="integer"
android:dashGap="integer"/>
<!--定义使用单种颜色填充-->
<solid android:color="color"/>
<!--定义为几何形状绘制边框-->
<stroke(画笔) android:width="integer"
android:color=""
android:dashWidth=""
android:dashGap="" />
</shape>
5.4 ClipDrawable
<?xml version="1.0" encoding="utf-8">
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/**"
android:clipOrientation="horizontal|vertical"(截取方向)
android:gravity=""(截取时的对齐方向)>
</clip>
ClipDrawable的对象可以调用setLevel(int)设置截取区域大小 0:空 10000:整张图片
ImageView imageview=(ImageView)findViewById(**)
final ClipDrawable drawable=(ClipDrawable) imageview.getDrawable();
drawable.setLevel(drawable.getLevel+20);
5.5 AnimationDrawable 资源
<?xml version="1.0" encoding="utf-8">
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator|accelerate_interpolator|decelerate_interpolator"
android:shareInterpolator(以下所有元素是否使用相同的动画速度)="true|false">
<alpha android:fromAlpha=""
android:toAlpha=""/>
<scale android:fromXScale=""
android:toXScale=""
android:fromYScale=""
android:toYScale=""
android:pivotX=""(缩放的中心点)
android:pivotY=""/>
<translate(平移) android:fromX=""
android:toX=""
android:fromY=""
android:toY=""/>
<rotate(旋转) android:fromDegrees=""
android:toDegrees=""
android:pivotX=""
android:pivotY=""/>
</set>
备注:那个元素在前面就先运行哪个元素
final ImageView image=....;
final Animation anim=AnimationUtils.loadAnimation(this,R.anim.my_anim);
//设置动画结束后保留结束状态
anim.setFillAfter(true);
image.startAnimation(anim);
6 Style(样式) 放在res/values
<?xml version="1.0" encoding="utf-8">
<resources>
<style name="style1">
<item name="android:textSize">20sp</item>
</style>
<style name="style2" parent="@style/style1">
<item name="android:textSize">30sp</item><!--覆盖父元素-->
</style>
</resources>
<EdtiText style="@style/style2"/>
7.Theme主题
<?xml version="1.0" encoding="utf-8">
<resources>
<style name="xlm">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowFrame">@drawable/window_border</item>
<item name="android:windowBackground">@drawable/start</item>
</style>
</resources>
1.setTheme(android.R.style.xlm);//java
2.<application android:theme="@style/xlm">
3.<activity android:theme="@style/xlm">
8 Attribute 属性资源
放在res/values
<?xml version="1.0" encoding="utf-8">
<resources>
<attr name="xlm">
</attr>
<!--定义一个styleable对象来组合多个属性-->
<declare-styleable name="xiedantibu">
<attr name="xlm">
</declare-styleable>
</resources>
TypedArray typedarray=context.obtainStyleAttributes(attrs,R.styleable.xiedantibu)
int xlm=typedarray.getInt(R.styleable.xiedantibu_xlm);
xmlns:xiedantibu="http://schemas.android.com/apk/res/项目包名"
xiedantibu:xlm="1000"
9.使用原始资源
1.在res/raw目录中放的资源: inputStream is=context.getResources().openRawResource(R.drawable.*);
2.位于/assets目录下的资源 1.AssetManager am=getAssets(); 2.InputStream open(String fileName)|(AssetFileDescirptor openFd(String fileName) -> AssetFileDescirptor.getFileDescriptor());
分享到:
相关推荐
[14本经典Android开发教程]-4-Android应用程序开发36技 本书共分为4篇: ※ 第一篇:介绍应用框架概念、原理和特性。 ※ 第二篇:阐述应用框架之设计技巧。亦即,如何打造应用框架。 (注:如果你的职务是「使用」...
ksoap2-android调用WebService 在Android中应用中的jar
android应用应用内更新解决方案
03-Android-APP-系统应用.pptx
第3章--Android基本应用程序.pptx
Android资源_01-Android开发环境搭建_实验01-Android开发环境搭建.pdf、实验02-Android应用开发HelloWorld.pdf; 02-Android Studio项目结构分析与调试_实验03-Android Studio项目结构分析.pdf、实验04-Android ...
[14本经典Android开发教程]-11-Android系统移植...[14本经典Android开发教程]-4-Android应用程序开发36技 http://download.csdn.net/detail/cleopard/8380495 [14本经典Android开发教程]-5-linux Android基础知识总结 ...
[14本经典Android开发教程]-7-Android编程入门...[14本经典Android开发教程]-4-Android应用程序开发36技 http://download.csdn.net/detail/cleopard/8380495 [14本经典Android开发教程]-5-linux Android基础知识总结 ...
Android高级应用源码-android二维码扫描,很好用的资源.zip
Android作为市场占有率最高的手机操作系统,为图片处理应用提供了广阔的市场空间。本项目旨在开发一款功能丰富、易于使用、性能稳定的Android图片特效处理应用,以满足用户对图片美化和创意处理的需求。本项目是一款...
Android-Skin-Loader ...> ...> > 一个通过动态加载本地皮肤包进行换肤的皮肤框架 ...├── android-skin-loader-sample // 皮肤库应用实例 ├── android-skin-loader-skin // 皮肤包生成demo └── skin-p
Android奇艺高清UI界面源代码,是一段精心编写的Android应用程序源代码,专注于实现一个高清且用户友好的奇艺视频应用界面。该源代码采用了现代化的UI设计理念,注重细节与用户体验,为用户提供了流畅、舒适的视频...
《Android应用程序开发教程(第2版)》教学课件02Android UI设计.pdf《Android应用程序开发教程(第2版)》教学课件02Android UI设计.pdf《Android应用程序开发教程(第2版)》教学课件02Android UI设计.pdf《Android应用...
Android应用程序主要由代码和资源组成。资源主要就是指那些与UI相关的东西,例如UI布局、字符串和图片等。代码和资源分开可以使得应用程序在运行时根据实际需要来组织UI。这样就可使得应用程序只需要编译一次,就...
Android应用加固检测技术与评估标准研究,魏国斌,李祺,随着移动互联网的发展以及移动应用安全问题的日渐突出,越来越多的移动应用都采用软件加固的方式进行自身代码和资源的保护。本文
新版Android开发教程+笔记十三(待续)--应用、permission、资源.pdf
3G-Android手机平台应用开发研究.pdf
平台上使用JaVa语言进行Android应用开发必须的工具和API接口。 特性 · 应用程序框架 支持组件的重用与替换 · Dalvik 虚拟机 专为移动设备优化 · 集成的浏览器 基于开源的WebKit 引擎 · 优化的图形库 包括定制的...
Android资源,Android应用程序,Android开发源码,android开发源程序