[Android Tips]Android 开发技巧 (一)

一直认为Andoid 官网是最强大,最权威的开发参考文档。里面有不少好东西,可以慢慢挖掘。

今天的Tips 是:

1.如果你指定了layout_weight, android:layout_width设置成0,可以提高性能。

In order to improve the layout efficiency when you specify the weight, you should change the width of the EditText to be zero (0dp). Setting the width to zero improves layout performance because using"wrap_content" as the width requires the system to calculate a width that is ultimately irrelevant because the weight value requires another width calculation to fill the remaining space.

2.

要在onStop 里处理完资源释放的操作, onDestory是靠不住的, 因为Stopped的App有可能被杀掉 而不执行调用onDestory() 

 

Stop Your Activity

When your activity receives a call to the onStop() method, it's no longer visible and should release almost all resources that aren't needed while the user is not using it. Once your activity is stopped, the system might destroy the instance if it needs to recover system memory. In extreme cases, the system might simply kill your app process without calling the activity's final onDestroy() callback, so it's important you use onStop() to release resources that might leak memory.

 

    <EditText        android:layout_weight="1"        android:layout_width="0dp"        ... />
posted @ 2012-05-04 01:11  Stanley.Luo  阅读(273)  评论(0编辑  收藏  举报