如何提高android布局渲染的性能

如何提高android布局渲染的性能,android,performance,templates,layout,render,Android,Performance,Templates,Layout,Render,我的android应用程序有8个模板布局 它们有不同的风格,比如重量,线的数量,有图标吗 它总是改变屏幕 它从充气模板布局所有8个布局开始 view1 = getLayoutInflater().inflate(R.layout.template_1, null); view2 = getLayoutInflater().inflate(R.layout.template_2, null); . . . view8 = getLayoutInflater().inflate(R.layout.t

我的android应用程序有8个模板布局

它们有不同的风格,比如重量,线的数量,有图标吗

它总是改变屏幕

它从充气模板布局所有8个布局开始

view1 = getLayoutInflater().inflate(R.layout.template_1, null);
view2 = getLayoutInflater().inflate(R.layout.template_2, null);
.
.
.
view8 = getLayoutInflater().inflate(R.layout.template_8, null);
并映射所有组件

layout = (LinearLayout) view.findViewById(R.id.layoutID);
line1 = (TextView) view1.findViewById(R.id.line1ID);
line2 = (TextView) view.findViewById(R.id.line2ID);
icon = (ImageView) view.findViewById(R.id.iconID);
我的代码正在检查模板的名称

范例

模板1

然后将view1添加到大型机

并配置所有组件

icon.setImageDrawable(....);
line1.setText(....);
line2.setText(....);
layout.setBackgroundColor(....);
这些都是我的步骤

  • 创建所有模板和映射id
  • 检查模板并选择
  • 配置所有组件
  • 添加到主框架
  • 当滑动到下一页时

  • 检查模板并选择
  • 配置所有组件
  • 添加到主框架
  • 循环

    如果我正常地滑到下一页就可以了。 但当我快速滑到下一页时,它会延迟

    是否有更好的配置和呈现新页面的解决方案

    我是android编程的新手。 对我的英语很抱歉


    谢谢您

    您使用哪一类进行分页?使用
    ViewPager
    您可以通过
    ViewPager.OnPageChangeListener(int preload PageCount)
    预加载远邻页面,从而缩短加载时间。只需新的xml文件您使用哪个类进行分页?使用
    ViewPager
    可以通过
    ViewPager.OnPageChangeListener(int preload PageCount)
    预加载远邻页面,从而缩短加载时间。只需新建xml文件即可