androidUI性能优化
来源:互联网 发布:淘宝欠款多少会被起诉 编辑:程序博客网 时间:2024/05/24 20:07
1、adapter 和adapterview 复用历史缓存(item布局和数据缓存)。
2、数据分页显示(利用操作引导用户)
3、优化布局文件xml。(layout尽量不要超过5层)
4、优化activity的背景图片。利用getWindow.setBackgroudDrawable(id)设置背景图,使用系统默认的最顶层来提高效率。
5、在自定义主题中设置背景
6、使用stubView按需加载,减少内存消耗
stubView要加载的布局:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"><TextView android:id="@android:id/text1" android:text="Portrait Mode" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <SeekBar android:id="@android:id/progress" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
延迟加载的主界面:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@android:id/button1"android:text="load"android:layout_width="wrap_content"android:layout_height="wrap_content"/> <ViewStub android:id="@+id/stub"android:inflatedId="@+id/subTree"android:layout="@layout/mystub_portrait"android:layout_width="match_parent"android:layout_height="match_parent" /> </LinearLayout>
stubView加载的实现
public class StubViewLoadActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.delay_load); Button btn = (Button) findViewById(android.R.id.button1); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { v.setEnabled(false); ViewStub stub = (ViewStub) findViewById(R.id.stub); View inflated = stub.inflate(); }}); }}
7、使用子线程和后台任务完成耗时操作
0 0
- androidUI性能优化
- AndroidUI显示原理及性能优化
- AndroidUI优化
- android 实践基础 AndroidUI性能优化-2015/06/11
- AndroidUI性能优化,标签的使用,ViewStub的使用
- AndroidUI的优化
- AndroidUI性能分析以及解决方法
- androidUI开发之-优化你的布局层次结构
- androidUi优化之--通过include标签来重用布局
- 性能优化
- 性能优化
- 性能优化
- 性能优化
- 性能优化
- 性能优化
- 性能优化
- 性能优化
- 性能优化
- android网络选择
- Eclipse使用之日常开发问题解答集锦
- Vmware 11 安装 Mac OS 提示不可恢复错误(vcpu-0)解决方法
- UVa 11733 Airports(变形的最小生成树)
- UITableView中添加UIFooterVIew是最后的分割线无法显示
- androidUI性能优化
- SSL/TLS的原理以及互联网究竟是如何工作的(3)—TLS的专场
- Git 解决eclipse pull报错
- Weka连接、访问MySQL数据库的办法
- mac 下压缩解压大全
- 碰撞图像shapes和polygon!
- Oracle 数据库 变更到 sqlserver 2008 中的一些经验
- 对XX证券报关于物联网操作系统的几个问题的答复
- UML9种图中的状态图