Improving Layout Performance(三)
Loading Views On Demand
有时你的布局可能需要一些复杂却又很少被用到的视图。无论他们是item详情、进度指示器,或撤销的消息,你都可以在需要时加载这些视图,来减少内存使用量并加快渲染速度。
Define a ViewStub
ViewStub是一个没有尺寸大小并且不会在布局中嵌套或渲染任何东西的轻量级的视图。因此在视图层次展现或隐藏它的代价非常小。每一个ViewStub仅仅需要包含android:layout属性来展现指定的布局。
以下ViewStub是一个半透明的进度条。他只有在新items被导入到应用中时才是可见的。
<ViewStub
android:id="@+id/stub_import"
android:inflatedId="@+id/panel_import"
android:layout="@layout/progress_overlay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
Load the ViewStub Layout
当你想要载入在ViewStub中定义的布局的时候,可以calling setVisibility(View.VISIBLE) or call inflate().
((ViewStub) findViewById(R.id.stub_import)).setVisibility(View.VISIBLE);
// or
View importPanel = ((ViewStub) findViewById(R.id.stub_import)).inflate();
注意:inflate()方法在视图渲染完毕后便直接展现该已渲染的视图View。因此如果你需要和布局交互的话,不需要再调用findViewById()方法
一旦一个ViewStub是可见的或渲染完毕,该元素便不再是视图层次的一部分。它被已渲染的布局替换,并且该布局的根视图的ID是在ViewStub中被android:inflatedId属性指定的ID。(在中被android:id指定的ID只有在这个ViewStub布局是可见/渲染完毕才是有效的。) 注意:ViewStub的一个缺点是,目前它在要渲染的布局中并不支持<merge/>标签
相关推荐
awesome-android-performance This is a list of awesome Android tutorials, videos and tools for performance optimization View Google Official Videos Double Layout Taxation Android Performance Patterns...
Priority Job Queue is an implementation of a Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
Today’s resource-intensive applications running on Intel® multi-core processor-based platforms are driving the need not only for greater networking bandwidth, but also for more efficient processing ...
该标准文档的标题“Improving the Lightning Performance”(提升雷电性能)主要指通过一系列技术和方法来提高电力系统中架空配电线路对于雷电冲击的抵抗能力。在电力行业中,“雷电性能”的提升通常涉及到对现有...
ChatMessagesAdapter for Android QuickBlox simple to use UI library for showing quickblox chat messages inside android application. Features Ready-to-go QBChatMessage view adapter with a set of view ...
"921164-MB51-Improving the runtime using database"这个主题主要关注通过优化数据库来提高MB51和类似事务如MMBE的运行性能。 首先,了解数据库优化的重要性是关键。在SAP系统中,大部分业务流程都需要与数据库...
本文《Improving Lookup Performance over a widely-deployed DHT》聚焦于Kademlia协议,一种广泛部署的DHT,旨在探讨并优化其查找性能。 ### 核心知识点 #### 1. DHT与Kademlia简介 DHT是一种分布式数据存储机制...
Sharing Spark RDD states between different Spark applications for improving performance. Processing events & streaming data, integrate Apache Ignite with other frameworks like Storm, Camel, etc. ...
藏经阁-Improving Python and Spark Performance and Interoperability 在本篇文章中,我们将讨论如何提高 Python 和 Spark 的性能和互操作性。Spark 是一个基于 Scala 编写的分布式计算框架,运行在 Java 虚拟机...
### 基于模板的方法提升WS-Security性能 #### 概述 随着Web服务在全球范围内的广泛应用,确保这些服务的安全性和可靠性的需求日益增长。为了满足这一需求,一系列与Web服务安全相关的规范被提出,其中最核心的是WS...
然而,"2020-自校正网络20cvpr-SCNet-Improving Convolutional Networks with Self-Calibrated Convolutions"这篇论文提出了一种新的思路,即不通过调整网络架构,而是改进CNN的基础卷积特征转换过程来提升性能。...
The investigation produced detailed measurements in order to profile the application and help on improving the performance. Code analysis shows that the current IPOP version suffers from ...
在.NET平台上,托管代码性能优化是一个重要课题,微软官方文档提供了一系列的设计和编程技巧来帮助开发者提升其.NET应用程序的性能。本章的目的是提供一系列优化和改进托管代码性能的技术,指导开发者编写可以充分...
Optimizing Java_Practical Techniques for Improving JVM Application Performance-O’Reilly(2018) How do you define performance? Most developers, when asked about the performance of their application, ...
Radically reducing development time and improving development experience. Cloudopt Next absorbed the ideas of Spring Boot,JFinal,Resty,Vertx and other excellent projects, and not only had a very ...
藏经阁-Improving Python and Spark Performance and Interoperability with Apache Arrow 本篇文章介绍了 PySpark UDF(User Defined Functions)的当前状态和限制,并讨论了 Apache Arrow 如何改进 PySpark UDF ...
https://engineering.instagram.com/improving-comment-rendering-on-android-a77d5db3d82e http://ragnraok.github.io/textview-pre-render-research.html Features 1.Faster than Android TextView 2.More ...