title: How to change gravity of indicator of widget TabLayout in Android
body: <p>Here I'm trying to change the position of <code>TabIndicator</code> to top from bottom but not getting success. I want just like as image is showing.
  I have done everything but indicator is in bottom not in top and even I can't add dividers between Tabs too. Please look at my code and help me to solve this issue.</p>
  
  <p>My code is like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"&gt;
  
   &lt;com.cws.widget.MyTabLayout
      android:id="@+id/mainTabLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginBottom="1dp"
      app:tabBackground="@color/drawer_tab_background"
      app:tabGravity="fill"
      app:tabIndicatorColor="@color/green"
      app:tabMode="fixed" /&gt;
  
  
  &lt;com.cws.widget.NonSiwpablePager
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>And styles.xml</p>
  
  <pre><code>&lt;style name="AppCompatTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;&lt;/style&gt;
  
  &lt;style name="AppToolbarTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
      &lt;!-- Customize your theme here. --&gt;
      &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
      &lt;item name="colorPrimary"&gt;#000&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
      &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
      &lt;item name="colorControlNormal"&gt;#FFF&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>MyTabLayout.java</p>
  
  <pre><code>public class MyTabLayout extends TabLayout {
  public MyTabLayout(Context context) {
      super(context);
  }
  
  public MyTabLayout(Context context, AttributeSet attrs) {
      super(context, attrs);
  }
  
  public MyTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
  }
  
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      int height = 0;
      for (int i = 0; i &lt; getChildCount(); i++) {
          View child = getChildAt(i);
          child.measure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
          int h = child.getMeasuredHeight();
          if (h &gt; height) height = h;
      }
      heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  
  }
  }
  </code></pre>
  
  <p>ViewPager.java</p>
  
  <pre><code>public class NonSiwpablePager extends ViewPager {
  public NonSiwpablePager(Context context) {
      super(context);
  }
  
  public NonSiwpablePager(Context context, AttributeSet attrs) {
      super(context, attrs);
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
      return false;
  }
  
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
      return false;
  }
  }
  </code></pre>