SlidingTabLayout не отображает заголовок

я использую этот учебник для скольжения: http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html, а класс Sliding взят из репозитория Google.

основная деятельность

ViewPager pager;
    ViewPagerAdapter adapter;
    SlidingTabLayout tabs;
    CharSequence Titles[]={"Home","Events"};
    int Numboftabs =2;     

class...
adapter =  new ViewPagerAdapter(getSupportFragmentManager(),Titles,Numboftabs);

        // Assigning ViewPager View and setting the adapter
        pager = (ViewPager) findViewById(R.id.pager);
        pager.setAdapter(adapter);

        // Assiging the Sliding Tab Layout View
        tabs = (SlidingTabLayout) findViewById(R.id.tabs);
        tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width

        // Setting Custom Color for the Scroll bar indicator of the Tab View
        tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
            @Override
            public int getIndicatorColor(int position) {
                return getResources().getColor(R.color.tabsScrollColor);
            }
        });

        // Setting the ViewPager For the SlidingTabsLayout
        tabs.setViewPager(pager);

Адаптер:

package com.leifacil.vademecum.Activities;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

/**
 * Created by hp1 on 21-01-2015.
 */
public class ViewPagerAdapter extends FragmentStatePagerAdapter {

    CharSequence Titles[]; // This will Store the Titles of the Tabs which are Going to be passed when ViewPagerAdapter is created
    int NumbOfTabs; // Store the number of tabs, this will also be passed when the ViewPagerAdapter is created


    // Build a Constructor and assign the passed Values to appropriate values in the class
    public ViewPagerAdapter(FragmentManager fm,CharSequence mTitles[], int mNumbOfTabsumb) {
        super(fm);

        this.Titles = mTitles;
        this.NumbOfTabs = mNumbOfTabsumb;

    }

    //This method return the fragment for the every position in the View Pager
    @Override
    public Fragment getItem(int position) {

        if(position == 0) // if the position is 0 we are returning the First tab
        {
            Tab1 tab1 = new Tab1();
            return tab1;
        }
        else             // As we are having 2 tabs if the position is now 0 it must be 1 so we are returning second tab
        {
            Tab2 tab2 = new Tab2();
            return tab2;
        }


    }

    // This method return the titles for the Tabs in the Tab Strip

    @Override
    public CharSequence getPageTitle(int position) {

        return Titles[position];
    }

    // This method return the Number of tabs for the tabs Strip

    @Override
    public int getCount() {
        return NumbOfTabs;
    }
}

я не знаю почему, но он не отображает заголовок =/

я не могу вставлять изображения, так что вот:

http://i.stack.imgur.com/A2ct8.png

вторую ссылку я не могу поставить как изображение -_-, но второе изображение /Jnihu.png

Отредактируйте .xml:

 <com.mypackage.Tools.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="@android:color/holo_green_dark"
    android:layout_below="@+id/toolbar_top"
        android:layout_alignParentLeft="true" />
    <android.support.v4.view.ViewPager
        android:id="@+id/pager"

        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tabs"></android.support.v4.view.ViewPager>

person Senhor Obvio    schedule 10.08.2015    source источник
comment
Вы также можете опубликовать xml?   -  person Abhishek    schedule 10.08.2015
comment
ofc =), добавив ему 1 минуту   -  person Senhor Obvio    schedule 10.08.2015
comment
@Senhor Obvio Где находится ваш метод populateTabStrip() в приведенном выше коде? Вы применили TextColor() для TabTitleView?   -  person Dhruv    schedule 10.08.2015
comment
@DhruvVaishnav я пробовал это tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { @Override public int getIndicatorColor(int position) { return getResources().getColor(R.color.tabsScrollColor); } });   -  person Senhor Obvio    schedule 10.08.2015
comment
и tabsScrollColor -> ``` ‹color name=tabsScrollColor›#ffffff‹/color› ```   -  person Senhor Obvio    schedule 10.08.2015
comment
@SenhorObvio попробуйте эту демонстрацию tutorialsbuzz.com/2015/04 /   -  person IntelliJ Amiya    schedule 10.08.2015


Ответы (1)


Пытаться

android:elevation="2dp" 

в ваших ToolBar и SlidingTabLayout

Но

Pre-Lollipop не поддерживает это свойство, поэтому вы можете использовать тени :( но это немного сложно

person HB MAAM    schedule 26.12.2015