Is it possible to change color of selected tab on v4 ViewPager?
I need to use v4 ViewPager, but I don't find any source to customize it.
Just to clarify I need to change the blue color to another one:
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
The
ViewPager
is not the one you need to customize. You need to set thetabIndicatorColor
of theTabLayout
linked with it in the layout.Dynamically you could do
Inside the XML, that would be as simple as the following
This is the tab indicator. You can change its color by applying different styles.
Use Action Bar Style Generator, generate 9patch png files (tab_selected, tab_selected_focused etc.) and add these files + styles to your project.
Another approach -> How to change the current tab highlighter color in Android ViewPager? (as @Pratik wrote in comment).
I don't have enough reputation to comment on an Answer, but regarding the Action Bar Style Generator make sure after you add the files to the corresponding folders in your project that you also add the theme to your manifest xml file like this:
Same way i don't find the way to customize the tab. So i have fixed it using
I have put this code with each 3 tabs belove the tab & above viewPager. As we can detect that which tab is selected very easily. So we can use this 'line1' visibility to View.VISIBLE or View.INVISIBLE.
Hope it helps to you!!