Napotkałem inny problem z ViewPagerem i nie mogę rozwiązać go z obecną wiedzą.Problem związany z pakowaniem zawartości TabPage w Androidzie:
Mam TabPageIndicator z ViewPager i na każdej karcie, wyświetlam tekst. To proste TextView:
<?xml version="1.0" encoding="utf-8"?>
<view xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="viewpagerindicator.TabPageIndicator$TabView" >
<TextView
android:id="@+id/vpi_tab_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center"
android:paddingBottom="10dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="10dip"
android:textColor="@drawable/vpi_tab_text_color"
android:typeface="serif" />
</view>
chcę tekst na karcie, aby być zawsze w jednej linii i być zawsze cały tekst, a nie ellipsize, bez owijania, nie więcej niż 1 wiersz. Jest to wymagane, aby użytkownik mógł odczytać go w całości ...
Ale nie mogę tego zrobić, próbowałem różnych opcji i nadal napotykam pewne problemy - albo tekst ma więcej niż jedną linię, ale wyświetlana jest tylko pierwsza z nich lub wyświetlana jest tylko część tekstu.
Czy doświadczyłeś czegoś podobnego?
Każda pomoc jest mile widziana
EDIT ONE:
Wierzę, że problem jest tutaj:
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
setFillViewport(lockedExpanded);
final int childCount = mTabLayout.getChildCount();
if (childCount > 1 && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
if (childCount > 2) {
mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
} else {
mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec)/2;
}
} else {
mMaxTabWidth = -1;
}
final int oldWidth = getMeasuredWidth();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int newWidth = getMeasuredWidth();
if (lockedExpanded && oldWidth != newWidth) {
// Recenter the tab display if we're at a new (scrollable) size.
setCurrentItem(mSelectedTabIndex);
}
}
mMaxTabWidth ...
próbowałem tego, ale to nie działa – Shehabix