ViewPager Background is grey. I can't find on internet any clear article that shows how to just change that background color in black for example.Any idea will be appreciated.
You can achieve it in 2 ways,
1.Add the following in your ViewPager in the xml
android:background="#000000"
2.Do it dynamically like below,
ViewPager pager= (ViewPager)findViewById(R.id.pager);
pager.setBackgroundColor(Color.BLACK);
Try this
private ViewPager mPager;
mPager = (ViewPager) view.findViewById(R.id.pager);
mPager.setBackgroundColor(Color.BLACK);
A ViewPager is not grey by default, it's transparent like other ViewGroups, so you will see your parent layout background or window background by default.
If you want to change the background color of your whole Activity, I suggest that you override the android:windowBackground attribute in your Activity's theme, which is more efficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With