溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

【移動開發(fā)】Android中各種xml匯總

發(fā)布時間:2020-08-11 23:16:48 來源:網(wǎng)絡(luò) 閱讀:1349 作者:zhf651555765 欄目:開發(fā)技術(shù)

   Android中xml使用十分廣泛,這里簡單匯總一下,使其更加系統(tǒng)化!


1.arrays.xml     定義數(shù)組

<resources>
     <string-array name="newstitle">
         <item>國際</item>
         <item>國內(nèi)</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  旋轉(zhuǎn)動畫

<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 旋轉(zhuǎn)動畫效果 
                                                   
        屬性:interpolator 指定一個動畫的插入器,用來控制動畫的速度變化 
                                                   
        fromDegrees 屬性為動畫起始時物件的角度     
        toDegrees   屬性為動畫結(jié)束時物件旋轉(zhuǎn)的角度,+代表順時針 
        duration  屬性為動畫持續(xù)時間,以毫秒為單位 
 --> 
 </set>


    以上這些就是android中常用的xml,至于其他的自行查閱嘍~


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI