ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
Apache License 2.0
7.09k stars 1.34k forks source link

tab is below of viewpager #39

Closed subhanshuja closed 9 years ago

subhanshuja commented 9 years ago

viewpager_indicator

can i put indicator on bottom of app? and how because your sample is on the top of app thank you

ogaclejapan commented 9 years ago

Hi, @subhanshuja

Of course you can place the indicator on bottom.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">

    <com.ogaclejapan.smarttablayout.SmartTabLayout
        android:id="@+id/viewpagertab"
        android:layout_width="match_parent"
        android:layout_height="@dimen/tab_height"
        android:layout_alignParentBottom="true"
        app:stl_distributeEvenly="true"
        app:stl_dividerThickness="0dp"
        app:stl_indicatorInterpolation="smart"
        app:stl_indicatorThickness="0dp"
        app:stl_underlineThickness="0dp" />

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/viewpagertab" />

</RelativeLayout>
subhanshuja commented 9 years ago

oh i just change the position of parent, thank you @ogaclejapan

subhanshuja commented 9 years ago

thank you for your @ogaclejapan tips last week, but now i have a problem with position of indicator thickness indicator_cannot_be_center

and i had tried to change position with gravity and it doesn't change, it this my code, please help me again

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bg_app"
    android:weightSum="2">

    <include layout="@layout/toolbar"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1.8">

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.21"
        android:background="@color/redPrimary">

        <com.ogaclejapan.smarttablayout.SmartTabLayout
            android:id="@+id/indicator"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:stl_customTabTextLayoutId="@layout/custom_circle"
            app:stl_dividerColor="@android:color/transparent"
            app:stl_dividerThickness="0dp"
            app:stl_indicatorAlwaysInCenter="false"
            app:stl_indicatorColor="@color/orange"
            app:stl_indicatorCornerRadius="16dp"
            app:stl_indicatorInterpolation="linear"
            app:stl_indicatorGravity="center"
            app:stl_indicatorThickness="16dp"
            app:stl_underlineColor="@android:color/transparent"
            app:stl_underlineThickness="0dp"/>

    </LinearLayout>

</LinearLayout>
ogaclejapan commented 9 years ago

Hi, @subhanshuja If you fix here, I think that it is displayed correctly.


...

<com.ogaclejapan.smarttablayout.SmartTabLayout
            android:id="@+id/indicator"
            android:layout_width="wrap_content"
            android:layout_gravity="center_horizontal"
            ...
/>

...
subhanshuja commented 9 years ago
<com.ogaclejapan.smarttablayout.SmartTabLayout
            android:id="@+id/indicator"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            app:stl_indicatorAlwaysInCenter="true"
            app:stl_customTabTextLayoutId="@layout/custom_circle"
            app:stl_dividerColor="@android:color/transparent"
            app:stl_dividerThickness="0dp"
            app:stl_indicatorColor="@color/orange"
            app:stl_indicatorCornerRadius="16dp"
            app:stl_indicatorInterpolation="linear"
            app:stl_indicatorGravity="center"
            app:stl_indicatorThickness="16dp"
            app:stl_underlineColor="@android:color/transparent"
            app:stl_underlineThickness="0dp"/>

and the result are

indicator_1 indicator_2 indicator_3

ogaclejapan commented 9 years ago

Hi, @subhanshuja

android:orientation must be vertical.

layout_gravity is because not activated.


<LinearLayout
  ...
  android:orientation="vertical"
  ...
  >

    <com.ogaclejapan.smarttablayout.SmartTabLayout
      android:layout_width="wrap_content"
      ...
      android:layout_gravity="center_horizontal"    
      ...
    />

</LinearLayout>

Because it is not in the library of the problem, to close.

subhanshuja commented 9 years ago

oke thank you for your help @ogaclejapan