EditText软键盘与光标

android中EditText有光标不弹出软键盘处理 当我们点击Edittext时(获得焦点),都会弹出系统默认的软键盘,在有时候会需要做到点击EditText不想显示软键盘,这时候我们就要想方法把软键盘给你从隐藏掉。有几种方法 方法一:在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden。(但是还是会弹出软键盘) 方法二:强制隐藏Android输入法窗口(此方法mouse在EditText中输入文本时会自动换行,但是会弹出软键盘)还有一个方法是这样的imm.toggleSoftInput(0, InputMethodManager.HIDEN ...

SVG与VectorDrawable

VectorDrawable是通过代码的形式构造 svg 矢量图; SVG Path 规则简介: M = moveto 起点(x,y) L = lineto 移动到(x,y) H = horizontal lineto 水平移动到(x) V = vertical lineto 垂直移动到(y) C = curveto 三次贝塞尔曲线(x1,y1,x2,y2,x,y) (x1,y1)(x2,y2)是开始和结束的控制点 S = smooth curveto 三次贝塞尔曲线(x2,y2,x,y) (x2,y2)是结束的控制点, 第一个控制点默认是前一个C或S的第二个控制点的反向, 前一个不是C或S, 则第一个控制点与当前点重合 Q = 二次贝塞尔曲线(x1,y1,x,y) 控制点(x1,y1) T = 二次贝塞尔曲线( ...

单元测试 — UIAutomator2.0

UI 自动化测试 听说可以模拟屏幕操作, 感觉挺有意思的, 有机会就学了一下; // 今天试了下, 模拟点击屏幕, 可惜一秒只可以点击5~6次, (ノ ̄(エ) ̄)ノ 添加依赖 androidTestCompile 'com.android.support.test:runner:0.4' // Set this dependency to use JUnit 4 rules androidTestCompile 'com.android.support.test:rules:0.4' // Set this dependency to build and run Espresso tests androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' ...

单元测试 — JUnit

JUnit(测试纯java代码) 官网 注解 注解 说明 @Test 该方法是测试方法 @Before 该方法在测试方法之前执行,一个Test触发一次 @After 该方法在测试方法之后执行,一个Test触发一次 @BeforeClass 该static方法在类的所有方法之前执行 @AfterClass 该static方法在类的所有方法之后执行 @Ignore 该方法不执行 套件测试 同时运行多个文件里的单元测试用例 @RunWith(Suite.class) @Suite.SuiteClasses({ TestJunit1.class, TestJunit2.class }) ...

蓝牙固件升级总结

公司需要做一个蓝牙模块的升级程序, 需要做成一个android apk, 主要使用 java 和 C(jni) 来实现; 准备 首先就是要先熟悉固件的升级文档, 按照流程来做, 一开始没有熟悉文档, 出了一些问题; 其次我这个模块升级模式和指令模式时的串口配置是不同的, 升级时需要开启偶校验, 串口配置需要注意; 技术实现 模块的升级, 说白了也就是把将升级文件替换模块里已存在的文件, 也是数据的收发, 只不过在发文件前需要一些准备工作, 每一步按照文档就好了; 文件的读取我使用了RandomAccessFile这个java类, 再借助 MappedByteBuffer 的 get 方法获 ...

DialogFragment

有Dialoge样式的Fragment, 同 Fragment 有同样的生命周期 继承 DialogFragment 的子类 Activity 中 DialogFragment 的子类对象调用 show (FragmentManager manager, String tag)显示 DialogFragment 的方法 getDialog() 可获取默认的 Dialoge getArguments() 返回一个 Bundle 对象 setStyle (int style,int theme)设置样式, 例: .setStyle(DialogFragment.STYLENOFRAME, 0);//去掉标题 show (FragmentManager manager, String tag) 显示该 DialogeFragment 注意 在Activity中用 FragmentTransaction 调用add和show方法显示 ...

内存分析工具(MAT)

作用

  • 查看内存使用情况
  • 查看某个类它对象占用的内存和引用数量
  • 分析GC

安装(eclipse)

  • 打开Eclipse – >help – > Install New Software
  • http://download.eclipse.org/mat/1.6/update-site/ (安装时1.6为最新)
  • 安装完成后提示重启Eclipse,重启后打开window – > open perspective->Memory Analysis ,说明安装成功

使用

使用方法详见: https://segmentfault.com/a/1190000003991636

作为一个 android 开发者学会使用MAT还是挺有意思的

PopupWindow 总结

构造方法 public PopupWindow (View contentView, int width, int height) // contentView 内容 // width 宽 // height 高 PopupWindow(View contentView, int width, int height, boolean focusable) // focusable 为 true 时, 返回键隐藏,可输入... 1234567 public PopupWindow (View contentView, int width, int height)// contentView 内容// width 宽// height 高 PopupWindow(View contentView, int width, int height, boolean focus ...

LinearGradient 线性渐变

LinearGradient 用来对某一个区域进行线性渐变, 父类为 Shader 构造参数 LinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions, Shader.TileMode tile) // 参数分别为 x0,y0为起始点坐标; x1,y1为结束点坐标; colors为渐变的颜色数组; positions 为颜色数组对应的起始位置, 为null时就是指colors均匀分布; tile 指的就是颜色渐变的平铺方式 LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, Shader.TileMode tile) // 参 ...