Android Manifest之receiver元素中文注释

语法(SYNTAX): <receiver android:enabled=["true" | "false"] android:exported=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:permission="string" android:process="string" > . . . </receiver> ...

七月 1, 2018 · 1 分钟 · LengYue

Android5.0通知变化浅析

目前在Android中通知的使用还是很常见的,为了做版本兼容,常用兼容包NotificationCompat.Builder和 Notification.Builder。 NotificationCompat.Builder位于v4扩展包内(version 4 Support Library) Notification.Builder在Android 3.0 开始引入(API level 11). 最近在Android5.0设备上发现一个问题:通知图标突然变成了白色的方块而不是代码中设置的icon。 问题原因 细读开发者文档其实也可以发现一些线索,虽然笔者是直接查的源码发现的问题原因。http://developer.android.com/design/patterns/notifications.html 一文的Use distinct icons部分介绍了几点关于通知的建议,其中的有两点是建议开发者不要做的行为。 Don’t Place any additional alpha (dimming or fading) into your small icons and action icons; they can have anti-aliased edges, but because Android uses these icons as masks (that is, only the alpha channel is used), the image should generally be drawn at full opacity. Don’t Use color to distinguish your app from others....

七月 1, 2018 · 1 分钟 · LengYue

Android实现图片缩放与旋转

本文使用Matrix实现Android实现图片缩放与旋转。示例代码如下: package com.android.matrix;import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ImageView.ScaleType; /** * Android实现图片缩放与旋转。 * @author Administrator * */ public class MatixActivity extends Activity { public void onCreate(Bundle icicle) { super.onCreate(icicle); setTitle("Android实现图片缩放与旋转。"); LinearLayout linLayout = new LinearLayout(this); //加载需要操作的图片,这里是一张图片 Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.r); //获取这个图片的宽和高 int width = bitmapOrg....

七月 1, 2018 · 1 分钟 · LengYue

Android将汉字转换成拼音

采用了单利的模式,可以查看里面的注释 /** * Java汉字转换为拼音 * */ public class CharacterParser { private static int[] pyvalue = new int[] {-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032, -20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728, -19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261, -19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961, -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490, -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988, -17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692, -17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733, -16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419, -16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959, -15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631, -15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180, -15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941, -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857, -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353, -14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094, -14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831, -13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329, -13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860, -12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300, -12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358, -11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014, -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309, -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254}; public static String[] pystr = new String[] {"a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian", "biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai", "chan", "chang", "chao", "che", "chen", "cheng", "chi", "chong", "chou", "chu", "chuai", "chuan", "chuang", "chui", "chun", "chuo", "ci", "cong", "cou", "cu", "cuan", "cui", "cun", "cuo", "da", "dai", "dan", "dang", "dao", "de", "deng", "di", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du", "duan", "dui", "dun", "duo", "e", "en", "er", "fa", "fan", "fang", "fei", "fen", "feng", "fo", "fou", "fu", "ga", "gai", "gan", "gang", "gao", "ge", "gei", "gen", "geng", "gong", "gou", "gu", "gua", "guai", "guan", "guang", "gui", "gun", "guo", "ha", "hai", "han", "hang", "hao", "he", "hei", "hen", "heng", "hong", "hou", "hu", "hua", "huai", "huan", "huang", "hui", "hun", "huo", "ji", "jia", "jian", "jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan", "kang", "kao", "ke", "ken", "keng", "kong", "kou", "ku", "kua", "kuai", "kuan", "kuang", "kui", "kun", "kuo", "la", "lai", "lan", "lang", "lao", "le", "lei", "leng", "li", "lia", "lian", "liang", "liao", "lie", "lin", "ling", "liu", "long", "lou", "lu", "lv", "luan", "lue", "lun", "luo", "ma", "mai", "man", "mang", "mao", "me", "mei", "men", "meng", "mi", "mian", "miao", "mie", "min", "ming", "miu", "mo", "mou", "mu", "na", "nai", "nan", "nang", "nao", "ne", "nei", "nen", "neng", "ni", "nian", "niang", "niao", "nie", "nin", "ning", "niu", "nong", "nu", "nv", "nuan", "nue", "nuo", "o", "ou", "pa", "pai", "pan", "pang", "pao", "pei", "pen", "peng", "pi", "pian", "piao", "pie", "pin", "ping", "po", "pu", "qi", "qia", "qian", "qiang", "qiao", "qie", "qin", "qing", "qiong", "qiu", "qu", "quan", "que", "qun", "ran", "rang", "rao", "re", "ren", "reng", "ri", "rong", "rou", "ru", "ruan", "rui", "run", "ruo", "sa", "sai", "san", "sang", "sao", "se", "sen", "seng", "sha", "shai", "shan", "shang", "shao", "she", "shen", "sheng", "shi", "shou", "shu", "shua", "shuai", "shuan", "shuang", "shui", "shun", "shuo", "si", "song", "sou", "su", "suan", "sui", "sun", "suo", "ta", "tai", "tan", "tang", "tao", "te", "teng", "ti", "tian", "tiao", "tie", "ting", "tong", "tou", "tu", "tuan", "tui", "tun", "tuo", "wa", "wai", "wan", "wang", "wei", "wen", "weng", "wo", "wu", "xi", "xia", "xian", "xiang", "xiao", "xie", "xin", "xing", "xiong", "xiu", "xu", "xuan", "xue", "xun", "ya", "yan", "yang", "yao", "ye", "yi", "yin", "ying", "yo", "yong", "you", "yu", "yuan", "yue", "yun", "za", "zai", "zan", "zang", "zao", "ze", "zei", "zen", "zeng", "zha", "zhai", "zhan", "zhang", "zhao", "zhe", "zhen", "zheng", "zhi", "zhong", "zhou", "zhu", "zhua", "zhuai", "zhuan", "zhuang", "zhui", "zhun", "zhuo", "zi", "zong", "zou", "zu", "zuan", "zui", "zun", "zuo"}; private StringBuilder buffer; private String resource; private static CharacterParser characterParser = new CharacterParser(); public static CharacterParser getInstance() { return characterParser; } public String getResource() { return resource; } public void setResource(String resource) { this....

七月 1, 2018 · 6 分钟 · LengYue

Android的图片压缩类ThumbnailUtils

缩放图片目前一共有3中方式: 第一种是BitmapFactory和BitmapFactory.Options。 第二种是使用Bitmap加Matrix来缩放。 第三种是用2.2新加的类ThumbnailUtils来做。 ...

七月 1, 2018 · 1 分钟 · LengYue

FastJson简单使用

在工作中,经常客服端需要和服务端进行通信,目前很多项目都采用JSON的方式进行数据传输,简单的参数可以通过手动拼接JSON字符串,但如果请求的参数过多,采用手动拼接JSON字符串,出错率就非常大了。并且工作效率也特别低。 我在网上看了一些开源的JSON框架,比如Google提供的Gson,Jackson,FastJson等框架。 经过测试,个人觉得FastJson执行效率比较高,而且简单易用。 FastJson不依赖于第三方包, 直接可以运行在Java JDK1.5之上,FastJson完全支持http://json.org 的标准,支持各种JDK类型,包括基本类型、JavaBean、Collection、Map、Enum、泛型等 还支持循环引用。 FastJson项目是开源的:Fastjson代码托管在github.org上,项目地址是:https://github.com/AlibabaTech/fastjson 一个JSON库涉及的最基本功能就是序列化和反序列化。Fastjson支持java bean的直接序列化。使用com.alibaba.fastjson.JSON这个类进行序列化和反序列化。 简单的序列化 pubic class UserInfo implements Serializable{ private String name; private int age; public void setName(String name){ this.name=name; } public String getName(){ return name; } public void setAge(int age){ this.age=age; } public int getAge(){ return age; } } public class TestOne{ public static void main(String[] args){ UserInfo info=new UserInfo(); info....

七月 1, 2018 · 1 分钟 · LengYue

tools:context=“.MainActivity”的作用

<TextView android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:layout_centerHorizontal=“true” android:layout_centerVertical=“true” android:text=“@string/hello_world” tools:context=“.MainActivity” /> 一直对于 tools:context=”.MainActivity”这句不懂,今天查了下,发现是这样的: tools:context=”activity name”这一句不会被打包进APK。只是ADT的Layout Editor在你当前的Layout文件里面设置对应的渲染上下文,说明你当前的Layout所在的渲染上下文是activity name对应的那个activity,如果这个activity在manifest文件中设置了Theme,那么ADT的Layout Editor会根据这个Theme来渲染你当前的Layout。就是说如果你设置的MainActivity设置了一个Theme.Light(其他的也可以),那么你在可视化布局管理器里面看到的背景阿控件阿什么的就应该是Theme.Light的样子。仅用于给你看所见即所得的效果而已。

七月 1, 2018 · 1 分钟 · LengYue

为可以滚动的View设置Padding和滚动条时需要注意什么

这个tips由Android Developers分享自Google+的, 我觉得这个tip对于UI体验确实很有用,所以我自己也写了一个demo来看看效果到底怎样,不过到底要不要这样做,取决于你的app的整体设计了。我们 可能经常为可以滚动的container(容器)设置padding和scrollbar,比如ListView、GridVie和ScrollView 等,但我们却忽略了几个重要的属性,导致这样设置之后效果并不是很好。 如何你在具有滚动功能的容器上设置paddingTop 和paddingBottom属性之后,你必须确保你已经设置clipToPadding?属性为false 来保证当内容滚动的时候,paddingTop 和paddingBottom随之“滚掉”,如果你不这样做的话,你的内容就像在很小的地方滚动一样,这可能导致你的app在视觉上出现故障。 如果你设置了paddingLeft 或者paddingRight——很好,paddingTop或者paddingBottom,确保滚动条相对应在内容上面,而应该尽可能地在屏幕的边缘。为了达到这样的效果,只需要简单的设置scrollbarStyle属性为outsideOverlay。 <ListView … android:clipToPadding=”false” android:scrollbarStyle=”outsideOverlay” /> 总的来说就是,当你为容器(可以滚动的)设置了padding属性之后,你应该同时也设置 效果图如图所示: 原文: Today’s?#AndroidDev?and?#AndroidDesign?#Protip?from+Roman Nurik?is about padding and scroll indicators for scrollable containers like list views. We do quite a bit of app UI review here on the Android Developer Relations team and one of the common issues with UI fit-and-finish we come across is improper padding and scroll indicators for padded scroll containers like?...

七月 1, 2018 · 2 分钟 · LengYue