本文用来记录在Android开发中经常用到的一些用法
arrays.xml定义数组
例:

<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"

要获取这种背景所对应的类型为:Drawable:GradientDrawable,我们可以改变它的颜色,而保持背景不变。

颜色相关

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

uses-permission

弹窗口时,在Manifest中添加:

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

资源文件与类的对应关系

selector对应的是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 对应的是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关联

以下两步缺一不可
step1: 指定一个Action常量:

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

step2:在对应的Activity中指定对应的IntentFilter

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

2. Notification是通过Action来区别的,不是通过ID来区别的

持续更新中

更多相关文章

  1. android有序广播和无序广播的区别
  2. ColorMatrixColorFilter颜色过滤(离线用户的灰色头像处理)
  3. Android(安卓)ListView 滑动背景为黑色的解决办法
  4. Android请求服务器的两种方式--post, get的区别
  5. 安卓Android面试题汇总
  6. 歌词效果制作
  7. Android(安卓)使用selector设置button字体颜色无效
  8. Android(安卓)项目中设置背景图片
  9. Android之加载图片时自定义进度条

随机推荐

  1. android:gravity和android:layout_gravit
  2. Xposed框架之函数Hook学习
  3. Android(安卓)C/C++ 开发
  4. ANDROID音频系统散记之一:A2dpAudioInterf
  5. 为Android加入busybox工具
  6. android之buttonBar的设计--style的引用
  7. android的selector,背景选择器
  8. Android(安卓)UI控件之ToggleButton、Swi
  9. Android核心分析 之十-------Android(安
  10. android控件的对齐方式