سلام دوستان من یک tablayout با 6 تب دارم که برای ایجاد تبها از تب سفارشی استفاده کردم. این کد مربوط به فایل xml تب سفارشی است:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:layout_centerHorizontal="true"
android:id="@+id/tabIcon"/>
<CustomViews.CustomTextView
android:id="@+id/basket_badge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:background="@drawable/notification_circle"
android:padding="2dp"
android:textColor="#ffffff"
android:textSize="8sp" />
<CustomViews.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/tab_inactive"
android:textSize="8sp"
android:layout_centerHorizontal="true"
android:layout_below="@id/tabIcon"
android:layout_marginBottom="2dp"
android:maxLines="1"
android:id="@+id/tabTitle"/>
</RelativeLayout>
که شامل آیکن تب ، یک badge و یک textview برای نمایش عنوان تب هست. کد زیر هم مربوط به فرگمنتیه که tablayout قرار دارده:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="scrollable"
app:tabMaxWidth="0dp"
android:layoutDirection="rtl"
android:id="@+id/avatar_tabLayout"
app:tabIndicatorColor="@null"
/>
</LinearLayout>
مشکلی که هست اینه که عنوان تبها طولانیه و اگه tabMode رو حالت fixed قرار بدم بعضی از کلمات عنوان تب رو حذف میکنه و وقتی هم رو حالت scrollable میزارم به هر تب فضای زیادی رو اختصاص میده تقریبا هر تب تو یه صفحه.
ممنون میشم اگه کمک کنید