Using Tab Widgets How can I view the second tab design when implementing tabs?

Asked 2 years ago, Updated 2 years ago, 161 views

Hi, how are you?

I'm implementing tabs using Android Studio. I'm using a tab widget. (TabWidget)

I would like to ask you how you can view the second tab2 in the design of the Android studio for the xml creation.

In the picture below, Tab1 can be selected and modified How do I modify it in Tab2?

I'm just a beginner. I ask for your help.

Thank you.

android tab tabwidget studio

2022-09-21 23:21

1 Answers

If you're going to implement TabItem directly from XML

You can add TabItem to TabLayout as follows:

<android.support.design.widget.TabLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorPrimary">

                <android.support.design.widget.TabItem
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="TAB1"/>

                <android.support.design.widget.TabItem
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="TAB2"/>

                <android.support.design.widget.TabItem
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="TAB3"/>


</android.support.design.widget.TabLayout>

And to implement a separate layout for TabItem

You can add layout properties to recall the xml corresponding to TabItem layout.

<android.support.design.widget.TabItem
                    android:layout="@layout/tabItemLayout"
                    android:text="TAB1"/>


2022-09-21 23:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.