我将包含ImageViews的自定义视图添加到标签。向标签添加图标后性能下降
在这里,我得到的布局:
LinearLayout view = (LinearLayout) getLayoutInflater().inflate(
R.layout.custom_actionbar_tab_1, null);
ImageView image1 = (ImageView) view.findViewById(R.id.image1);
image1.setImageResource(R.drawable.icon_28799);
LinearLayout view2 = (LinearLayout) getLayoutInflater().inflate(
R.layout.custom_actionbar_tab_2, null);
ImageView image2 = (ImageView) view2.findViewById(R.id.image2);
image2.setImageResource(R.drawable.icon_20321);
LinearLayout view3 = (LinearLayout) getLayoutInflater().inflate(
R.layout.custom_actionbar_tab_3, null);
ImageView image3 = (ImageView) view3.findViewById(R.id.image3);
image3.setImageResource(R.drawable.icon_39547);
在这里,我设置自定义视图选项卡:
actionBar.addTab(actionBar.newTab().setCustomView(view)
.setTabListener(this));
actionBar.addTab(actionBar.newTab().setCustomView(view2)
.setTabListener(this));
actionBar.addTab(actionBar.newTab().setCustomView(view3)
.setTabListener(this));
但是当我测试它在模拟器应用迅速放缓,它永远在标签之间滑动。图标位于一个可绘制的文件夹中。有人有类似的问题?
当测试性能时,我不确定我会信任模拟器。您是否在实际设备上进行了测试? – Knossos 2014-09-23 15:26:05
我使用genymotion,这对于模拟器来说非常快速...因为我将图标添加到了应用程序的标签缓慢。当我删除图标时,速度很快。 – Sini 2014-09-23 15:47:39
好吧我找到了。这是图像尺寸减慢了性能。我调整了每个denisty的大小 – Sini 2014-09-23 15:51:07