温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-08-11 23:16:48 来源:网络 阅读:1337 作者:zhf651555765 栏目:开发技术

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


1.arrays.xml     定义数组

<resources>
     <string-array name="newstitle">
         <item>国际</item>
         <item>国内</item>
         <item>军事</item>
    </string-array>
</resources>


2.colors.xml 定义颜色

<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   定义尺寸

<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 定义画布

<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 定义字符串

<resources>
       <string name="app_name">Beem</string>
       <string name="OkButton">Ok</string>
       <string name="ClearButton">Clear</string>
</resources>


6.styles.xml 定义样式

<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    

<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 菜单

<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  旋转动画

<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,至于其他的自行查阅喽~


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI