android-tablayout

How do I change the color of icon of the selected tab of TabLayout?

让人想犯罪 __ 提交于 2019-11-28 16:18:23
I'm using a TabLayout with a ViewPager and I'm wondering how I can most efficiently change the color of the icon of the selected tab in the TabLayout. A perfect reference for how this is implemented is Google's Youtube app . On the main page, there are four icons that are colored dark gray. When a specific tab is selected, the tab's icon becomes white. Without any third party libraries , how can I achieve the same effect? One possible solution is apparently with selectors. But in that case, I would have to find both a white and a gray version of the icon and then switch the icon when the tab

Tablayout with icons only

假装没事ソ 提交于 2019-11-28 16:03:50
I am using design support to create tabs. I am also using ViewPager for swipable tabs. Now, I don't know how to use only icons instead of texts in tabs. I tried finding out but didn't get any success. My code: Toolbar toolbar; private TabLayout tabLayout; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.pager); setupViewPager(viewPager); setupTablayout(); } private void setupTablayout() { tabLayout = (TabLayout) findViewById(R.id

Android ViewPager Loading incorrect fragments

你离开我真会死。 提交于 2019-11-28 12:38:05
So I'm trying to get a tab bar and layout underneath my main navigation bar working on my main activity. I can't seem to get the ViewPager/TabLayout (unsure which is the cause of the problem, new to this) to load the correct fragment. I've read through a ton of documentation and checked more than 1 tutorial to see if I was doing this correctly and it seems that I'm doing the same thing they are... The OnTabSelectedListener for my TabLayout is seeing the tab changes properly, and in OnTabSelected Im calling viewPager.setCurrentItem(tab.getPosition()) to attempt to set my viewpagers item, but it

Difference between PagerTabStrip and TabLayout

a 夏天 提交于 2019-11-28 09:02:55
I am working on an app where I want to add tabs so that can be added using PagerTabStrip and TabLayout with ViewPager. It looks same to me with no difference but I guess there is some difference between them so they are two classes for this. So what is the main difference between them? Just comparing the visuals... TabLayout is a material concept that replaced the deprecated ActionBar tabs in Android 5.0. It extends HorizontalScrollView , so you can keep adding tabs horizontally which can include text, icons, or custom views and scroll through them linearly without paging. TabLayout provides

TabLayout tabs text not displaying

百般思念 提交于 2019-11-28 07:07:42
I am using TabLayout inside a Fragment to display three fixed tabs and the tabs are working but it doesn't show the tab text even after I set the app:tabTextColor attribute in the layout it's still not visible. NewFragment.java public class NewFragment extends Fragment { private RecyclerView mRecyclerView; private RecyclerView.LayoutManager mLayoutManager; private RecyclerView.Adapter mAdapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflatedView = inflater.inflate(R.layout.new_fragment, container, false); TabLayout

Can a custom view be used as a TabItem?

本秂侑毒 提交于 2019-11-28 06:54:11
The TabLayout class in android provides you with a TabItem that can let you specify a text and a icon. Is it possible to use a custom view as a TabItem? My tab would look like this as you can see besides an icon and a text label, I also have a notification symbol (a number inside a yellow circle). how can I make tabs like this? In certain cases, instead of the default tab view we may want to apply a custom XML layout for each tab. To achieve this, iterate over all the TabLayout.Tabs after attaching the sliding tabs to the pager: public class MainActivity extends AppCompatActivity { @Override

Android Tablayout tabs with notification badge like whatsApp

蓝咒 提交于 2019-11-28 05:28:44
I want to implement notification badge with android.support.design.widget.TabLayout . I had tried my best effort to implement it but fails. Any help would by greatly appreciated. My solution to this was using https://github.com/jgilfelt/android-viewbadger and setting a custom view to each tab: My tabs have only icons so I used ImageView, but I believe you can use any other view, check https://github.com/jgilfelt/android-viewbadger/blob/master/README.markdown : private BadgeView badge; Tab tab = tabLayout.getTabAt(position); ImageView imageView = new ImageView(context); tab.setCustomView

Using TabLayout inside a Fragment; tab text invisible

夙愿已清 提交于 2019-11-28 05:01:18
I'm currently experimenting with various new components in the new Android Support Design library . I've implemented a NavigationView in my MainActivity.java , which uses a FragmentManager to navigate between the items in the Navigation drawer: getSupportFragmentManager() .beginTransaction() .replace(R.id.content, mTabLayoutFragment) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) .commit(); I'm using a TabLayout in one of the fragments. Here is the fragment's layout: <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=

Tabs don't fit to screen with tabmode=scrollable, Even with a Custom Tab Layout

大憨熊 提交于 2019-11-28 02:16:10
I have made a custom TabLayout with a ViewPager and am using the TabLayout in scrollable mode: I need it to be scrollable as the number of dates can vary to as many as 15-20: <com.example.project.recommendedapp.CustomScrollableTabLayout android:id="@+id/tab_layout_movie" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:elevation="6dp" android:minHeight="?attr/actionBarSize" app:tabGravity="fill" app:tabMode="scrollable" app:tabTextAppearance="?android:textAppearanceMedium" android:theme="@style/ThemeOverlay.AppCompat.Dark

Design support library tabs with only icons

徘徊边缘 提交于 2019-11-28 01:45:32
问题 I am using design support library to create tabs. By default it creates tabs with text. How can I create tabs with only icons? Also I want to change the icons color if it's current selected tab. 回答1: Use this to populate the viewPager: public class SectionPagerAdapter extends FragmentPagerAdapter { public SectionPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { switch (position) { case 0: return mFragmentA; case 1: return mFragmentB; case 2: