gpt4 book ai didi

android - 选项卡布局内容未显示在 fragment 布局内

转载 作者:太空狗 更新时间:2023-10-29 13:03:30 26 4
gpt4 key购买 nike

我有一个 BottomNavigationView,它有三个选项卡。一个 BottomNavigationView 包含 TabLayout。我的问题是为什么 TabLayout 内容没有显示。仅显示选项卡标题。

这是一个 XML fragment 。

 <android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/txt_profile_about_me"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:textAlignment="viewStart"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_gathring_count" />



<android.support.design.widget.TabLayout
android:id="@+id/profile_tabs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"

app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_profile_about_me"
app:layout_constraintVertical_bias="1.0"
/>

<android.support.v4.view.ViewPager
android:id="@+id/profile_viewpager"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/white"/>

</android.support.constraint.ConstraintLayout>

我的代码如下。

    ViewPager viewPager = (ViewPager) view.findViewById(R.id.profile_viewpager);
ProfileTabAdapter adapter = new ProfileTabAdapter(getChildFragmentManager());

// Set the adapter onto the view pager
viewPager.setAdapter(adapter);

// Give the TabLayout the ViewPager
TabLayout tabLayout = (TabLayout) view.findViewById(R.id.profile_tabs);
tabLayout.setupWithViewPager(viewPager);

标签内容未显示。任何建议。

最佳答案

适本地约束您的 viewPager。

试试这个:

    <android.support.v4.view.ViewPager
android:id="@+id/profile_viewpager"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/profile_tabs"
app:layout_constraintBottom_toBottomOf="parent"/>

关于android - 选项卡布局内容未显示在 fragment 布局内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52165374/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com