Android SlidingTabLayout with icons

Just want to give example for the Correct and accepted answer. 🙂 Firstly, add the tabs and set their custom view when you are adding the adapter to your viewpager. For example see following lines: mViewpager = (ViewPager) view.findViewById(R.id.pager); //Do something with your view before setting up adapter ViewPager.setAdapter(mSectionsPagerAdapter); mSlidingTabLayout = (SlidingTabLayout) View().findViewById(R.id.sliding_tabs); mSlidingTabLayout.setCustomTabView(R.layout.custom_tab_title, R.id.tabtext); … Read more

Add Icons to SlidingTabLayout instead of Text

The key to this is to return a SpannableString, containing your icon in an ImageSpan, from your PagerAdapter’s getPageTitle(position) method: private int[] imageResId = { R.drawable.ic_tab_notifications, R.drawable.ic_tab_weather, R.drawable.ic_tab_calendar }; @Override public CharSequence getPageTitle(int position) { Drawable image = getResources().getDrawable(imageResId[position]); image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight()); SpannableString sb = new SpannableString(” “); ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM); … Read more

Importing Facebook library in Android Studio: Could not find property ‘ANDROID_BUILD_SDK_VERSION’

First of all, you can add this dependency to your project, without compiling the lib locally. dependencies { compile ‘com.astuetz:pagerslidingtabstrip:1.0.1’ } Otherwise if you would like to compile this lib locally, you have to define these keys in gradle.properties in the root. ANDROID_BUILD_TARGET_SDK_VERSION=19 ANDROID_BUILD_TOOLS_VERSION=19 ANDROID_BUILD_SDK_VERSION=19