Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
yuanliwei / html 禁用按钮点击时的默认背景色.md
Created February 3, 2016 09:03
html 禁用按钮点击时的默认背景色

html 禁用按钮点击时的默认背景色

-webkit-tap-highlight-color: rgba(255, 0, 0, 0);

@yuanliwei
yuanliwei / javascript 遍历js对象中的属性.md
Created February 3, 2016 09:05
javascript 遍历js对象中的属性

javascript 遍历js对象中的属性

			for ( var key in ansMap) {
				var lp = posMap[key];
			}
@yuanliwei
yuanliwei / Git配置默认pull、push地址.md
Last active February 18, 2016 02:14
Git配置默认pull、push地址

Git配置默认pull、push地址

  • git remote add -f origin https://github.com/simpleOrg/simpleApp.git
  • git config -e
  [core]
          symlinks = false
          repositoryformatversion = 0
          filemode = false
 logallrefupdates = true
@yuanliwei
yuanliwei / npm install 乱码解决方案.md
Created February 25, 2016 05:41
npm install 乱码解决方案

npm install 乱码解决方案

  • chcp切换cmd页码为65001 chcp 65001

npm/npm#10648

Seems that the character count of the progress bar is calculated to fill in just one line, then when the next line is outputed, last line is erased so the viewer see a growing progress bar But in Chinese code pages, the characters used by the bar are full width (regular ascii characters are "half width") , which means they take up the space of 2 characters (this can be seen obviously in the first picture I posted here), and as a result the progress bar output to 2 lines, and broke itself.

@yuanliwei
yuanliwei / VideoDownProgressView.java
Created March 11, 2016 09:16
Android drawText 文字垂直居中
float textWidth = paintOval.measureText(progressText);
Paint.FontMetricsInt fmi = paintOval.getFontMetricsInt();
float left = (width - textWidth) / 2;
float top = (height - fmi.bottom - fmi.top) / 2;
canvas.drawText(progressText, left, top, paintOval);
@yuanliwei
yuanliwei / 国内优秀npm镜像推荐及使用.md
Created March 11, 2016 13:27
国内优秀npm镜像推荐及使用
@yuanliwei
yuanliwei / android:descendantFocusability用法简析.md
Created April 1, 2016 03:33
android:descendantFocusability用法简析

android:descendantFocusability用法简析

开发中很常见的一个问题,项目中的listview不仅仅是简单的文字,常常需要自己定义listview,自己的Adapter去继承BaseAdapter,在adapter中按照需求进行编写,问题就出现了,可能会发生点击每一个item的时候没有反应,无法获取的焦点。原因多半是由于在你自己定义的Item中存在诸如ImageButton,Button,CheckBox等子控件(也可以说是Button或者Checkable的子类控件),此时这些子控件会将焦点获取到,所以常常当点击item时变化的是子控件,item本身的点击没有响应。

这时候就可以使用descendantFocusability来解决啦,API描述如下:

android:descendantFocusability

Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.

Must be one of the following constant values.

@yuanliwei
yuanliwei / ndroid 软键盘 显示、隐藏.md
Created April 27, 2016 05:36
ndroid 软键盘 显示、隐藏

Android 软键盘 显示、隐藏

InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);


  • 显示imm.showSoftInput(webView, InputMethodManager.SHOW_IMPLICIT);
  • 隐藏imm.hideSoftInputFromWindow(webView.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);