Closed vimosanan93 closed 2 years ago
Hello, has the same problem with TabLayout.
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
app:navigationIcon="@drawable/ic_back_blue"
app:title="Screen"/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@drawable/selector_tab_indicator"
app:tabIndicatorColor="@color/colorBlue"
app:tabIndicatorHeight="2dp"
app:tabSelectedTextColor="@color/colorBlue"
app:tabMode="auto"
app:tabTextAppearance="@style/AppTheme.TabLayout.TabTextAppearance"
app:tabTextColor="@color/colorTypographyGrey" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Tried app:tabMode="scrollable", app:tabMode="scrollable" and app:tabGravity="fill"
Can you provide screenshots?
I'll close the issue due to no further info available. Feel free to reopen it if it's still reproducible.
I still have the same issue, please see blow the detail.
Version implementation 'com.google.android.material:material:1.4.0'
`<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/transparent"
android:backgroundTint="@null"
app:elevation="0dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivBackButton"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignTop="@id/tvMoreTitle"
android:layout_alignBottom="@id/tvMoreTitle"
android:layout_alignParentStart="true"
android:layout_marginStart="24dp"
android:background="@drawable/selector_ripple"
android:scaleType="centerInside"
android:src="@drawable/icon_back" />
<TextView
android:id="@+id/tvMoreTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:fontFamily="@font/quicksand_bold"
android:letterSpacing="0.02"
android:lineSpacingExtra="4.8sp"
android:text="@string/personal_information_title"
android:textColor="@android:color/white"
android:textSize="19.2sp" />
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutPaymentsDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray_dark_common_background"
android:fontFamily="@font/quicksand_bold"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appBar"
app:tabBackground="@color/gray_dark_common_background"
app:tabIndicatorColor="@color/red_home_payments"
app:tabIndicatorGravity="bottom"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabSelectedTextColor="@android:color/white"
app:tabTextAppearance="@style/TabLayoutTheme"
app:tabTextColor="@color/gray_light_tab_layout_unselected_text" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPagerIformations"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="0.0">
</androidx.viewpager2.widget.ViewPager2>
</androidx.constraintlayout.widget.ConstraintLayout>
`
TabLayoutMediator( binding.tabLayoutPaymentsDetails, binding.viewPagerIformations ) { tab, position -> tab.text = when (position) { 0 -> getString(R.string.personal_information_contact_tab) 1 -> getString(R.string.personal_information_employment_tab) //Disabling this tab for now 2 -> getString(R.string.myinformation_tab_events) else -> "" } }.attach()
Description: I have a tab in my application at bottom. I am using com.google.android.material.tabs.Tablayout for it. The issues I'm facing is the two tabs getting centred with wrap content. I searched at max, most of the developers suggested set the
TabMaxWidth to 0dp, TabMode to Fixed and TabGravity to Fill.
I tried with this solution. But nothing is working for me. I'm dealing with this minor issues for more than a day.
Expected behavior: Tabs should be filled with the match parent width.
Source code:
` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
Android API version: For all api version, but for only HDpi and MDpi devices.
Material Library version: Materail version : 1.3.0-alpha01 Device: HDpi (Emulator)
To help us triage faster, please check to make sure you are using the latest version of the library.
We also happily accept pull requests.