【移动开发】Android中各种xml汇总

简介:

  Android中xml使用十分广泛,这里简单汇总一下,使其更加系统化!


1.arrays.xml     定义数组

1
2
3
4
5
6
7
<resources>
      <string-array name= "newstitle" >
          <item>国际</item>
          <item>国内</item>
          <item>军事</item>
     </string-array>
</resources>


2.colors.xml 定义颜色

1
2
3
4
5
6
7
8
9
10
11
<resources>
      <color name= "blue_sky" >#A0C8FF</color>
      <color name= "vert_manu" >#CCFF00</color>
      <color name= "black" ># 000000 </color>
      <color name= "white" >#FFFFFF</color>
      <color name= "red" >#FF0000</color>
      <color name= "link_color" >#FF0066CC</color>
      <color name= "simiple_button_color" >#FFF</color>
      <color name= "blue" >#0000FF</color>
      <color name= "grey" >#FFCBD2D8</color>
  </resources>


3.dimens.xml   定义尺寸

1
2
3
4
5
<resources>
         <dimen name= "bottom_tab_font_size" >12dp</dimen>
         <dimen name= "bottom_tab_padding_up" >5dp</dimen>
         <dimen name= "bottom_tab_padding_drawable" >8dp</dimen>
</resources>


4.drawables.xml 定义画布

1
2
3
4
5
6
7
<resources>
      <item type= "drawable"  name= "shader1" >#7f7f7f7f</item>
      <item type= "drawable"  name= "highlight" >#cf7f7f7f</item>
      <item type= "drawable"  name= "barbg" >#ef0a4267</item>
      <item type= "drawable"  name= "trans" ># 00000000 </item>
      <item type= "drawable"  name= "chatdivider" >#ffd6dadc</item>
</resources>


5.strings.xml 定义字符串

1
2
3
4
5
<resources>
        <string name= "app_name" >Beem</string>
        <string name= "OkButton" >Ok</string>
        <string name= "ClearButton" >Clear</string>
</resources>


6.styles.xml 定义样式

1
2
3
4
5
6
7
8
9
<resources>
         <style name= "Label" >
                 <item name= "android:textSize" >18sp</item>
                 <item name= "android:textStyle" >bold</item>
                 <item name= "android:typeface" >sans</item>
                 <item name= "android:focusable" > false </item>
                 <item name= "android:padding" >12dip</item>
         </style>
</resources>


7. selector选择(按下效果)  phoinix_popumenu_style.xml    

1
2
3
4
5
<selector xmlns:android= "http://schemas.android.com/apk/res/android" >
     <item android:state_focused= "true"  android:state_pressed= "true"   android:drawable= "@drawable/phoinix_pushmail_btn_selected"  />
     <item android:state_focused= "false"  android:state_pressed= "true"   android:drawable= "@drawable/phoinix_pushmail_btn_selected"  />
     <item android:state_focused= "true"  android:drawable= "@drawable/phoinix_small_selected" />
</selector>


8.menu 菜单

1
2
3
4
5
6
7
8
9
10
11
12
13
<menu xmlns:android= "http://schemas.android.com/apk/res/android" >
          <group>
                         <item android:id= "@+id/chat_menu_contacts_list"  android:visible= "true"
                          android:title= "@string/chat_menu_contacts_list"  android:icon= "@drawable/ic_menu_friendslist"  />
                                                                                       
                          <item android:id= "@+id/chat_menu_change_chat"  android:visible= "true"
                          android:title= "@string/chat_menu_change_chat"  android:icon= "@drawable/ic_menu_chat_dashboard"  />
          </group>
                                                                       
         <item android:id= "@+id/chat_menu_close_chat"  android:visible= "true"
          android:title= "@string/chat_menu_close_chat"  android:icon= "@drawable/ic_menu_end_conversation"  />
                                                               
</menu>



8.anim  旋转动画

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
< set  xmlns:android= "http://schemas.android.com/apk/res/android" >
                                                         
<rotate 
    android:interpolator= "@android:anim/accelerate_decelerate_interpolator"
    android:fromDegrees= "0" 
    android:toDegrees= "+360"
    android:duration= "3000"  />
  <!-- rotate 旋转动画效果
                                                    
         属性:interpolator 指定一个动画的插入器,用来控制动画的速度变化
                                                    
         fromDegrees 属性为动画起始时物件的角度    
         toDegrees   属性为动画结束时物件旋转的角度,+代表顺时针
         duration  属性为动画持续时间,以毫秒为单位
  -->
  </ set >


    以上这些就是android中常用的xml,至于其他的自行查阅喽~





     本文转自zhf651555765 51CTO博客,原文链接:http://blog.51cto.com/smallwoniu/1248892,如需转载请自行联系原作者



相关文章
|
8月前
|
XML 前端开发 Android开发
Android XML 布局基础(四)内外边距(margin、padding)
Android XML 布局基础(四)内外边距(margin、padding)
169 0
|
8月前
|
XML Java Android开发
#4,Android Studio Android程序结构 工程目录介绍 文件作用 运行配置文件AndroidManifest.xml
#4,Android Studio Android程序结构 工程目录介绍 文件作用 运行配置文件AndroidManifest.xml
|
8月前
|
XML Android开发 数据格式
Android Binary XML file line #50: Error inflating class androidx.cardview.widget.CardView 错误
Android Binary XML file line #50: Error inflating class androidx.cardview.widget.CardView 错误
52 0
|
8月前
|
XML 应用服务中间件 Android开发
Android的XML文件解析之PULL解析
Android的XML文件解析之PULL解析
|
8月前
|
XML Android开发 数据格式
Android XML 布局基础(八)帧布局 - GridLayout
Android XML 布局基础(八)帧布局 - GridLayout
90 0
|
8月前
|
XML Android开发 数据格式
Android XML 布局基础(七)帧布局 - FrameLayout
Android XML 布局基础(七)帧布局 - FrameLayout
54 0
|
8月前
|
XML Android开发 数据格式
Android XML 布局基础(六)相对布局 - RelativeLayout
Android XML 布局基础(六)相对布局 - RelativeLayout
103 0
|
8月前
|
XML Android开发 数据格式
Android XML 布局基础(五)线性布局 - LinearLayout
Android XML 布局基础(五)线性布局 - LinearLayout
85 0
|
XML Android开发 数据格式
|
XML JavaScript Android开发