ViewPagerIndicator - заголовки страниц TabPageIndicator случайным образом разбиваются на 2 строки
Иногда заголовок страницы в TabPageIndicator разбивается на 2 строки, иногда как целые слова, а иногда как разбитые слова. Вот несколько скриншотов
1) разбить на 2 строки - разбитые слова
2) Разделить на 2 строки - целыми словами
3) Не разбито на 2 строки
Вот мой код компоновки:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.viewpagerindicator.TabPageIndicator
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_gravity="top"
android:paddingTop="2dp"
android:layout_marginBottom="2dp" />
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="fill_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
Вот мой код стиля:
<style name="CustomTabPageIndicator">
<item name="footerColor">@color/brand</item>
<item name="android:colorBackground">@color/white</item>
<item name="footerLineHeight">1dp</item>
<item name="footerIndicatorHeight">3dp</item>
<item name="android:textColor">#FF555555</item>
<item name="android:textSize">13sp</item>
<item name="android:dividerPadding">5dp</item>
<item name="android:layerType">software</item>
<item name="android:showDividers">none</item>
<item name="android:fadingEdge">horizontal</item>
<item name="android:fadingEdgeLength">8dp</item>
<item name="selectedColor">#FF000000</item>
<item name="selectedBold">true</item>
<item name="android:gravity">center</item>
<item name="android:typeface">normal</item>
<item name="android:background">@drawable/custom_tab_indicator</item>
<item name="android:paddingLeft">10dip</item>
<item name="android:paddingRight">10dip</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
</style>
Может кто-нибудь сказать мне, что здесь не так, что заголовки страниц случайным образом разбиваются на 2 строки, а иногда нет?
2 ответа
В файле TabPageIndicator.java
mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
Вместо вышеупомянутого добавьте эту строку кода, и она сделает перенос текста
mTabLayout.addView (tabView, новый LinearLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT, 1));
Попробуйте добавить эту строку в свой код стиля...
<item name="android:maxLines">1</item>
Или же
ОБНОВИТЬ
Вы пытались добавитьsingleLine=true"
в стилях?