【发布时间】:2018-11-05 10:36:25
【问题描述】:
我正在使用viewPager,它有一个片段,而那个片段有一个recyclerView。我正在尝试同时显示viewPager 的所有选项卡。这是可能的还是有任何不同的方法来处理这种情况。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tabGravity="center"
android:layout_gravity="center_horizontal"
app:tabMode="scrollable"
app:tabPaddingEnd="1dp"
app:tabPaddingStart="1dp"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
</LinearLayout>
【问题讨论】:
-
试试
app:tabMode="fixed" -
@V-rundPuro-hit 我正在使用 app:tabMode="scrollable" 因为更多选项卡将在运行时添加并且能够水平滚动
-
好的..所以如果标签在屏幕上可见,您希望它们应该像那张图片一样位于中心?
-
@V-rundPuro-hit 不,我只希望所有选项卡同时显示它们的数据,即只有订单 1 显示其数据我想显示所有要显示的订单同时数据
-
同屏所有数据?
标签: android android-fragments android-viewpager recyclerview-layout