I need to change the font color for PagerTabStrip in ViewPager for my Android app. This is the xml layout for the same. Is there any way I can do this?
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/head"
android:id="@+id/myfivepanelpager">
<android.support.v4.view.PagerTabStrip
android:id="@+id/pgstrip"
android:layout_width="fill_parent"
android:background="@color/strip"
android:layout_height="@dimen/pagerstripht"
android:layout_gravity="top"
/>
</android.support.v4.view.ViewPager>
in your code :
<android.support.v4.view.PagerTabStrip
android:id="@+id/pgstrip"
android:layout_width="fill_parent"
android:background="@color/strip"
android:layout_height="@dimen/pagerstripht"
android:layout_gravity="top"
/>
I think adding android:textColor="#000" will change the text color.
If you haven't found out yet, code is below
PagerTabStrip pagerTabStrip = (PagerTabStrip) findViewById(R.id.pager_title_strip);
pagerTabStrip.setDrawFullUnderline(true);
pagerTabStrip.setTabIndicatorColor(Color.RED);
Get the child views of the PagerTabStrip and check if it is an instance of a TextView. If it is, set text color:
PagerTabStrip mPagerTabStrip = (PagerTabStrip) findViewById(R.id.pgstrip);
for (int i = 0; i < mPagerTabStrip.getChildCount(); ++i) {
View nextChild = mPagerTabStrip.getChildAt(i);
if (nextChild instanceof TextView) {
TextView textViewToConvert = (TextView) nextChild;
textViewToConvert.setTextColor(getResources().getColor(R.color.primary_text_color_dark_gray));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With