最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android開發(fā)之資源文件用法實例總結(jié)

 更新時間:2016年02月15日 11:07:49   作者:bigconvience  
這篇文章主要介紹了Android開發(fā)之資源文件用法,結(jié)合實例形式總結(jié)分析了Android開發(fā)過程中針對資源文件的常見操作技巧,需要的朋友可以參考下

本文實例總結(jié)了Android開發(fā)之資源文件用法。分享給大家供大家參考,具體如下:

這里記錄在Android開發(fā)中經(jīng)常用到的一些用法

arrays.xml定義數(shù)組

例:

<resources>
  <!-- share items --> 
  <string-array name="app_share_items">
    <item>新浪微博</item>
    <item>騰訊微博</item>
  </string-array> 
</resources>

純色圓角背景

<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="#4a90e2" />
  <corners android:radius="95dp" />
</shape>

用法:

android:background="@drawable/xml_background_button_blue"

要獲取這種背景所對應(yīng)的類型為:Drawable:GradientDrawable,我們可以改變它的顏色,而保持背景不變。

顏色相關(guān)

ps中:0透明,1完全不透
android:顏色格式:argb alpha:[0,255] 完全透明到完全不透明
粉紅:#8f0f

uses-permission

彈窗口時,在Manifest中添加:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

資源文件與類的對應(yīng)關(guān)系

selector對應(yīng)的是StateList

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:drawable="@drawable/xml_login_button_press"/>
  <item android:drawable="@drawable/xml_login_button_normal"/>
</selector>

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true">
    <shape>
      <solid android:color="@color/pressed_color"/>
    </shape>
  </item>
  <item>
    <shape>
      <solid android:color="@color/transparent"/>
    </shape>
  </item>
</selector>

shape 對應(yīng)的是GradientDrawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="#4a90e2" />
  <corners android:radius="95dp" />
</shape>

Notification

1. Action與Activity關(guān)聯(lián)

以下兩步缺一不可
step1: 指定一個Action常量:

public static final String DOWNLOAD_MANAGER = "com.james.app.download";

step2:在對應(yīng)的Activity中指定對應(yīng)的IntentFilter

<intent-filter>
  <action android:name="com.james.app.download"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

2. Notification是通過Action來區(qū)別的,不是通過ID來區(qū)別的

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android資源操作技巧匯總》《Android開發(fā)入門與進階教程》、《Android控件用法總結(jié)》、《Android短信與電話操作技巧匯總》及《Android多媒體操作技巧匯總(音頻,視頻,錄音等)

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論

青冈县| 连南| 纳雍县| 华亭县| 德惠市| 汽车| 阿合奇县| 杨浦区| 平安县| 秦皇岛市| 德化县| 丹棱县| 台中市| 伊金霍洛旗| 常宁市| 洞口县| 永济市| 凉城县| 大余县| 拜城县| 明溪县| 河津市| 鲁山县| 稷山县| 曲阜市| 靖江市| 怀宁县| 区。| 莎车县| 无极县| 西林县| 夏邑县| 剑川县| 调兵山市| 朝阳区| 黑山县| 武汉市| 丘北县| 循化| 永丰县| 灵璧县|