I use the PagerSlidingTabStrip from astuetz and i use icons in the selector. I have two fragments. The tabstrip is defined in the xml:
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/ptsOverview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
psts:pstsShouldExpand="true"
psts:pstsIndicatorHeight="5dp"
psts:pstsDividerColor="#FFFFFF"
psts:pstsIndicatorColor="@color/pts_indicator"/>
The problem is that i cant find the correct icon size. If the size is too large, the icon is shown as center crop. If the icon is too small it is shown ungly.
Any idea what the correct size of a icon? Thank you
OK i think i found at least a way to "modify" a little the tabs icons.
at Line 239
private void addIconTab(final int position, int resId) {
ImageButton tab = new ImageButton(getContext());
tab.setImageResource(resId);
addTab(position, tab);
}
You can see that he uses an ImageButton for sliding views so from here: What's the default ScaleType of ImageView? it says
the default ScaleType value is FIT_CENTER, but for a Button is "fitXY"
so the icons is being streched to fit X and Y right now. if you add this line to whatever you want like:
tab.setScaleType(ImageView.ScaleType.FIT_START);
or
tab.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
you could achieve some better results.. and finally find a solution that suits you..
Ofcourse you have to include PagerSlidingTabStrip project as a depencency in your .gradle config file in android studio..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.