0

The layout image

Hi! I'm using the ActionBar tabs, one activity and four fragments and what I'm trying to do is place the icon and the text in the center of the tab.

I tried this technique but it didn't work. I also tried setting the name="android:gravity to center. Also, I know it's not the best practice but I tried adding right padding to the tabs. I used vertical orientation in the TabView style to get the icons above the text.

Community
  • 1
  • 1
RubaRamm
  • 25
  • 6

1 Answers1

0

You must create layout: abs_layout

 <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
    android:layout_width="110dp"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:text="Title"
    android:textColor="#ffffff"
    android:id="@+id/action_bar_title"
    android:textSize="18sp" /></RelativeLayout>

and in OnCreate() add this

getSupportActionBar().setCustomView(R.layout.abs_layout);
Ted09
  • 41
  • 2