我正在使用带有两个嵌套片段的TabLayout,我注意到当用户单击另一个选项卡时,当内容立即更改时,指示器从第一个选项卡移动到第二个选项卡需要3-4秒。
到目前为止,我尝试过这款应用的任何设备都有相同的行为(不仅仅是genymotion)。Nexus 4和Nexus 5X是一些测试设备。
布局是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:EMVideoView="http://schemas.android.com/apk/res-auto"
android:background="@color/white"
android:clickable="true"
android:layout_width="match_parent" android:layout_height="match_parent">
<com.devbrackets.android.exomedia.EMVideoView
android:id="@+id/video_play_activity_video_view"
android:layout_width="match_parent" android:layout_height="360dp"
EMVideoView:defaultControlsEnabled="true"/>
<android.support.design.widget.TabLayout
android:id="@+id/nested_tabs" android:layout_below="@+id/video_play_activity_video_view"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
app:tabMode="fixed" app:tabGravity="fill"/>
<FrameLayout android:id="@+id/fl_nested_tabs_container" android:layout_below="@+id/nested_tabs"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
以及我更改选项卡的代码:
@Override
public void onTabSelected(TabLayout.Tab tab) {
if (isCommentsFragmentSelected) {
isCommentsFragmentSelected = false;
getChildFragmentManager()
.beginTransaction()
.replace(R.id.fl_nested_tabs_container, PollsFragment.newInstance())
.commit();
} else {
isCommentsFragmentSelected = true;
getChildFragmentManager()
.beginTransaction()
.replace(R.id.fl_nested_tabs_container, CommentsFragment.newInstance())
.commit();
}
}发布于 2019-10-08 21:02:12
在清单文件中的应用程序标记下使用此属性。
android:hardwareAccelerated="true"发布于 2016-12-24 14:55:05
我还在带有ViewPager的三选项卡布局中使用了嵌套片段。设置offscreen page limit为我解决了加载速度慢的问题。
viewPager.setOffscreenPageLimit(2);https://stackoverflow.com/questions/36667730
复制相似问题