Hello yaza,
Welcome to our Microsoft Q&A platform!
when I start the app, i can see the tabs but not the content of the tabitem.
This is because you set android:layout_height
to match_parent
for the FrameLayout
and set android:layout_height
to 0dp for the ViewPager
. To use android:layout_weight
, please set the android:layout_weight
for the views to wrap_content
instead.
<LinearLayout
android:orientation="vertical"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout_pos">
<FrameLayout
android:id="@+id/fragment_container_pos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.7" />
<com.google.android.material.tabs.TabLayout
android:layout_weight="0.3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
...>
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager_pos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.