linwoain的个人blog

知我者谓我心忧,不知我者谓我何求

0%

1、动画(Animation)
传统动画中,有位移、旋转、缩放、透明度变化等动画,如以下代码移动一个图片控件

1
2
3
4
TranslateAnimation animation = new TranslateAnimation(0, 200, 0, 0);
animation.setDuration(1000);
animation.setFillAfter(true);//使控件停留到动画结束的位置,若不设置则返回原来位置
iv.startAnimation(animation);

但iv的属性却留在了原地。iv的事件响应只在原来位置生效。而属性动画这可以实现属性随控件移动,如下句:

1
ObjectAnimator.ofFloat(iv, "translationX", 0, 200).setDuration(1000).start();

这句与以上代码会

有相同的动画效果,且iv的响应事件也会跟随控件移动。
translationX或者translationY都是指控件的偏移量,也可以使用X,Y 指的是控件位置变化,如下句:ObjectAnimator.ofFloat(iv, “Y”, 0, 200).setDuration(1000).start();这个方法的第二个参数是指控件中有get,set方法的属性名。只要有get与set方法就可以使用这种方法操作。如下句:

1
ObjectAnimator.ofFloat(iv, "rotation", 0, 360).setDuration(1000).start();翻转360

而若这三个动画放到一起,如下:

1
2
3
ObjectAnimator.ofFloat(iv, "rotation", 0, 360).setDuration(1000).start();
ObjectAnimator.ofFloat(iv, "Y", 0, 200).setDuration(1000).start();
ObjectAnimator.ofFloat(iv, "translationX", 0, 200).setDuration(1000).start();
阅读全文 »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/** 判断手机是否root,不弹出root请求框 */
public static boolean isRoot() {
String binPath = "/system/bin/su";
String xBinPath = "/system/xbin/su";
if (new File(binPath).exists() && isExecutable(binPath)) return true;
return new File(xBinPath).exists() && isExecutable(xBinPath);
}
private static boolean isExecutable(String filePath) {
Process p = null;
try {
p = Runtime.getRuntime().exec("ls -l " + filePath); // 获取返回内容
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String str = in.readLine();
LLogUtils.i(str);
if (str != null && str.length() >;= 4) {
char flag = str.charAt(3);
if (flag == 's' || flag == 'x') return true;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (p != null) {
p.destroy();
}
}
return false;
}

最近公司的项目开始使用Android Studio开发,发现使用maven的库构建项目确实很方便也不用下载太多的库了,版本控制也容易了许多。于是决定把自己这两年来积累的库分享出来。首先在网上搜了一下教程。就找到了这篇文章http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0227/2502.html 然后按照里面的步骤一步步来。
首先要在https://bintray.com/申请一个账号,之后点击自己的头像进入自己的主页


然后点开Edit

阅读全文 »

listview中如果item中有控件默认抢占焦点将导致item的click事件失效。解决方法有二

  1. 在抢占焦点的控件中声明
1
android:focusable="false"
  1. 在item布局的根节点注明
1
android:descendantFocusability="blocksDescendants"

1.window.location.href方式

1
2
3
4
5
6
7
8
9
10
11
   <script language="javascript" type="text/javascript">
window.location.href="target.aspx";
</script>
```
**2.window.navigate方式跳转**

```javascript
<script language="javascript">
window.navigate("target.aspx");
</script>

阅读全文 »