mt0*_*t0s 5 android android-tablayout
我正在使用TabLayout两个嵌套的片段,我注意到当用户点击另一个Tab时,内容立即改变,指示器从第一个Tab移动到第二个Tab需要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"/>
Run Code Online (Sandbox Code Playgroud)
和我更改标签的代码:
@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();
}
}
Run Code Online (Sandbox Code Playgroud)
Sur*_*gch -2
我还在 ViewPager 的三选项卡布局中使用了嵌套片段。设置离屏页面限制解决了我加载缓慢的问题。
viewPager.setOffscreenPageLimit(2);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1033 次 |
| 最近记录: |