zoukankan      html  css  js  c++  java
  • android 学习笔记1- 应用程序的资源管理

    android 应用程序依赖不同的应用资源:字符,字符串,颜色,尺寸,可以绘制对象,图形,动画,布局等,可以用R.java来访问。getResources()来获取对象。

     资源类型          XML标签          动作函数                
     字符串  <string>  getString(),getText()保留字符串格式。格式变量正确转义Utils.htmlEncode()然后String.format();
     字符串复数  <plurals>, <item> R.plurals.访问资源。getQuatityString()获取字符串资源的复数形式。 国际化语言支持时候,
     字符串数组  <string-array>,<item>  getStringArray()
     boolean  <bool>  getBoolean()
     color state <selector>, <item>   getColor()
     dimension <dimen>   getDimension()
     ID <item>   
    Integer  <integer>   getInteger()
    integer array  <integer-array>   getIntArray()
     mix arrays  <array>, <item>  
    可绘制 drawable

     简单的可绘制图形用<drawable>标签放在/res/values。可以创建可绘制对象子类xml文件放在/res/drawable下面。比如:shapeDrawable,ScaleDrawable,TransitionDrawable.clipDrawable,statListDrawable

    layerDrawable,bitmapDrawable.NinePatchDrawable.

     getDrawable()
    xml define shape   

     .icon, .jpg.png.

    setImageResource(),getDrawable(),

    getIntrinsicHeight.

     补间动画

    <set>,<alpha><scale>

    <translate><rotate> 

     fadesequence。setImageResource()后,使用基类Animation对象加载动画。AnimationUtils.loadAnimation(),然后控件启动动画。也可以采用匹配之类提取特定动画类型如:rotateAnimation ,scaleAnimation.alphaAnimation.
     属性动画

     <set><objectAnimator>

    <valueAnimator>

     
    帧动画   <animation-list>,<item>

    sequence1.xml.sequence2.xml 

    getDrawable()返回AnimationDrawable对象。然后分配到控件进行开始、停止等。

    菜单  <menu> 

     onCreateOptionsMenu()

    getMenuInflater().inflate(this, menu)

    xml, raw 文件   userdefine  .mp3, .mp4, .helptext.txt
    getXml(),openRawResource()
     layout    getLayout(),getLayoutParams()
    style &theme  <style> style1.xml, theme.xml 
         
         
  • 相关阅读:
    计数排序
    CSS3变形
    前端内存泄露问题
    复杂对象的深拷贝
    JavaScript基本数据类型——Symbol
    随机打乱数组
    唯一重复的数字
    src和href的区别
    iframe的缺点
    link和@import的区别
  • 原文地址:https://www.cnblogs.com/yangjunhe460/p/13536645.html
Copyright © 2011-2022 走看看