In the paint method, paint the page rectangle the color you want (in my case, I want it to follow the standard BackColor): // force the tab background to the current BackColor. I added a TabLayoutOnPageChangeListener: viewPagerFragments.addOnPageChangeListener(new TabLayout. Either in the designer or 'by hand', add a Paint event handler to the TabPage: .Paint + tabpagePaint // custom paint event so we get the backcolor we want. Then in onCreate: tupWithViewPager(viewPagerFragments, true) For example, in Red : I achieved to change the " programmatically by doing this: I've created a new default tab bar component for you by copying the component from source and modifying it to accept a new parameter called activeBackgroundColor.If you're using API level > 21 use it without ContextCompat like this: tBackground(getDrawable(R.drawable.badge)) tBackground(ContextCompat.getDrawable(this, R.drawable.your_drawable)) If you want to change the tabLayout background use this: TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs) TabLayout.getTabAt(tabLayout.getSelectedTabPosition()).setCustomView(R.layout.your_layout) (Set your custom view after set up the viewPager) TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs) You should manipulate p-tabview-panels in your scss (or css) of your component our globaly in style.scss (or css). If you want to change the selected tab background you can use this: This is my tab_color_selector.xml in drawable: Maybe i didn't read some exemple or question, but this is what i'm trying to accomplish. tBackground(ContextCompat.getDrawable(this, R.drawable.tab_color_selector)) I think the question is pretty clear, when i renderHeader to create the tabBar i want to have different background color for inactive and Active tab. tBackgroundDrawable(getResources().getDrawable(R.drawable.tab_color_selector)) tBackgroundResource((R.drawable.tab_color_selector)) These are what I've already tried but none of them is working: tBackground(getResources().getDrawable(R.drawable.tab_color_selector)) This is my code: It's a tabLayout that I setupWith a Viewpager Ä«ut how do I set this programmatically? is really important to set this tabBackground programmatically because I want the color to change depending on the theme that the user has chose
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |