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 
         
         
  • 相关阅读:
    python移动文件
    python分割多个分隔符
    pywintypes.com_error: (-2147418111, '被呼叫方拒绝接收呼叫。', None, None)
    MySQL查看和修改字符集的方法
    Django创建超级管理员用户
    P2567.[SCOI2009] windy 数(数位DP)
    920G.List of Integers(莫比乌斯函数+二分)
    916E.Jamie and Tree (倍增LCA+线段树维护DFS序)
    GYM100376F.Circle and Trees(树形DP+倍增LCA)
    GYM100376E.LinearMapReduce(线段树维护矩阵乘法)
  • 原文地址:https://www.cnblogs.com/yangjunhe460/p/13536645.html
Copyright © 2011-2022 走看看