Skip to content

Commit 38db0cc

Browse files
author
ge78fug
committed
Changed the color
1 parent ee217eb commit 38db0cc

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.schabi.newpipe.fragments;
22

33
import android.content.Context;
4+
import android.content.res.ColorStateList;
45
import android.os.Bundle;
56
import android.util.Log;
67
import android.util.TypedValue;
@@ -15,6 +16,7 @@
1516
import androidx.annotation.NonNull;
1617
import androidx.annotation.Nullable;
1718
import androidx.appcompat.app.ActionBar;
19+
import androidx.core.content.ContextCompat;
1820
import androidx.fragment.app.Fragment;
1921
import androidx.fragment.app.FragmentManager;
2022
import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround;
@@ -208,20 +210,28 @@ private void updateTabsPosition() {
208210
pagerParams.removeRule(RelativeLayout.BELOW);
209211
pagerParams.addRule(RelativeLayout.ABOVE, R.id.main_tab_layout);
210212
tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_TOP);
211-
final TypedValue typedValue = new TypedValue();
212-
getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue,
213+
final TypedValue typedValueBackground = new TypedValue();
214+
getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValueBackground,
213215
true);
214-
getActivity().getWindow().setNavigationBarColor(typedValue.data);
216+
tabLayout.setBackgroundColor(typedValueBackground.data);
217+
tabLayout.setTabRippleColor(ColorStateList.valueOf(
218+
getResources().getColor(R.color.gray)));
219+
tabLayout.setTabIconTint(ColorStateList.valueOf(getResources().getColor(R.color.gray)));
220+
tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.gray));
215221
} else {
216222
tabParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
217223
tabParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
218224
pagerParams.removeRule(RelativeLayout.ABOVE);
219225
pagerParams.addRule(RelativeLayout.BELOW, R.id.main_tab_layout);
220226
tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_BOTTOM);
221227
final TypedValue typedValue = new TypedValue();
222-
getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValue,
228+
getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue,
223229
true);
224-
getActivity().getWindow().setNavigationBarColor(typedValue.data);
230+
tabLayout.setBackgroundColor(typedValue.data);
231+
tabLayout.setTabRippleColor(binding.mainTabLayout.getTabRippleColor().withAlpha(32));
232+
tabLayout.setTabIconTint(binding.mainTabLayout.getTabIconTint());
233+
tabLayout.setSelectedTabIndicatorColor(ContextCompat
234+
.getColor(requireContext(), R.color.white));
225235
}
226236
tabLayout.setLayoutParams(tabParams);
227237
viewPager.setLayoutParams(pagerParams);

0 commit comments

Comments
 (0)