You can use a custom view to determine how you want to display your tabs.
- define a custom layout where you have an image above the text
- In your activity, inflate the presentation and set values ββfor your image and your text.
- set custom view for tab
Here is an example:
CUSTOMS PLAN
<?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" android:gravity="center_horizontal" android:orientation="vertical" > <ImageView android:id="@+id/tabIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:paddingTop="2dp" /> <TextView android:id="@+id/tabText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:textColor="#FFFFFF" /> </LinearLayout>
INFLATE VIEW
View tabView = activity.getLayoutInflater().inflate(R.layout.actiobar_tab, null); TextView tabText = (TextView) tabView.findViewById(R.id.tabText); tabText.setText(R.String.sometext); ImageView tabImage = (ImageView) tabView.findViewById(R.id.tabIcon); tabImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.someimage));
INSTALL CUSTOMS VIEW FOR PROVIDED TABLE
Tab tab = actionBar.newTab().setCustomView(tabView)
source share