How to change selected Tab Text color using TabLayout from code in Android?
If you are using the design support library add this code to your tab activity.
tabLayout.setSelectedTabIndicatorColor(Color.parseColor("#FF0000"));
tabLayout.setSelectedTabIndicatorHeight((int) (5 * getResources().getDisplayMetrics().density));
tabLayout.setTabTextColors(Color.parseColor("#727272"), Color.parseColor("#ffffff"));
This will set the tab text color as well as tab indicator color in your tab activity.
How to change to color of react-native-tab-view?
Changing the background color of the tab-bar
If you refer to this section, the styling props for the tab-bar will have to be passed after declaring a custom React component using the renderTabBar
prop.
<TabView
navigationState={{ index, routes }}
renderScene={renderScene}
onIndexChange={setIndex}
initialLayout={initialLayout}
renderTabBar={props => <TabBar {...props} style={{backgroundColor: 'black'}}/>} // <-- add this line
/>
Changing the text color of the tab-bar
If you refer to this,
<TabBar
renderLabel={({route, color}) => (
<Text style={{ color: 'black', margin: 8 }}>
{route.title}
</Text>
)}
style={{backgroundColor: 'white'}}
...
/>
Feel free to experiment further using the example snack. :)
How do I change a tab background color when using TabLayout?
What finally worked for me is similar to what @如果我是DJ suggested, but the tabBackground
should be in the layout
file and not inside the style
, so it looks like:
res/layout/somefile.xml
:
<android.support.design.widget.TabLayout
....
app:tabBackground="@drawable/tab_color_selector"
...
/>
and the selectorres/drawable/tab_color_selector.xml
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/tab_background_selected" android:state_selected="true"/>
<item android:drawable="@color/tab_background_unselected"/>
</selector>
Change the color of selected Tab, of TabMenu PRIMENG - style
Sorry for the delayed answer. Just to keep in mind you should add :host ::ng-deep
before your css class to override any style
:host ::ng-deep .ui-tabmenu .ui-tabmenu-nav .ui-tabmenuitem.ui-state-active {
background-color: #d90096; //<Replace your custom color>
border: 1px solid #d600d9;
}
Hopefully it will save your time.
How to change the selected tab background colours in flutter
Is this what you are looking for ?
class TabBarExample extends StatefulWidget {
@override
_TabBarExampleState createState() => _TabBarExampleState();
}
class _TabBarExampleState extends State<TabBarExample>
with SingleTickerProviderStateMixin {
// Define a tab controller object
TabController _tabController;
@override
void initState() {
_tabController = TabController(length: 3, vsync: this);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
color: Colors.grey[300],
child: TabBar(
controller: _tabController,
indicatorColor: Colors.transparent,
labelColor: Colors.pink,
unselectedLabelColor: Colors.grey,
labelStyle: TextStyle(
fontSize: 16,
),
unselectedLabelStyle: TextStyle(
fontSize: 16,
),
indicator: BoxDecoration(
color: Colors.white,
),
tabs: <Widget>[
Tab(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('STEP 1'),
Text(
'Investment',
style: TextStyle(
fontSize: 12,
),
),
],
),
),
Tab(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('STEP 2'),
Text(
'Investment',
style: TextStyle(fontSize: 12),
),
],
),
),
Tab(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('STEP 3'),
Text(
'Investment',
style: TextStyle(fontSize: 12),
),
],
),
),
],
),
),
),
);
}
}
OUTPUT:
How to change color of Selected Tab
I really recommend you to use the Actionbar Style Generator.
With that tool you can easily theme your graphic elements in your toolbar.
How to change selected tab title color in Xamarin
I need Black for selected tab and gray for unselected tab.
You don't need to use CustomRender to achieve this.
You can just use properties UnselectedTabColor
and SelectedTabColor
of TabbedPage
.
Please refer to the following code:
<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageWithNavigationPage;assembly=TabbedPageWithNavigationPage"
x:Class="TabbedPageWithNavigationPage.MainPage"
UnselectedTabColor="Gray"
SelectedTabColor="Black"
>
</TabbedPage>
TabBar icon color when tab is selected
To change the selected tab color, you just need to add this to TabBar :
labelColor: Colors.
unselectedLabelColor: Colors.white,
Full code:
DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
labelColor: Colors.deepOrange,
unselectedLabelColor: Colors.white,
tabs: <Tab>[
Tab(
child: Row(
children: <Widget>[
Text("Select", textAlign: TextAlign.start),
SizedBox(
width: 24.0,
),
Icon(
Icons.arrow_drop_down,
color: Colors.blue.shade400,
),
],
),
),
Tab(
child: Row(
children: <Widget>[
Text("Select", textAlign: TextAlign.start),
SizedBox(
width: 24.0,
),
Icon(
Icons.arrow_drop_down,
color: Colors.blue.shade400,
),
],
),
),
],
),
),
body: Center(
child: Container(
child: Text("This is a page blahblah"),
),
),
),
)
EDIT:
If u want to only change the icon color, then add color to Text and remove the color from the Icon in Tab, Code:
DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
labelColor: Colors.deepOrange,
unselectedLabelColor: Colors.white,
tabs: <Tab>[
Tab(
child: Row(
children: <Widget>[
Text("Select", textAlign: TextAlign.start, style: TextStyle(color: Colors.white),),
SizedBox(
width: 24.0,
),
Icon(
Icons.arrow_drop_down,
),
],
),
),
Tab(
child: Row(
children: <Widget>[
Text("Select", textAlign: TextAlign.start, style: TextStyle(color: Colors.white),),
SizedBox(
width: 24.0,
),
Icon(
Icons.arrow_drop_down,
),
],
),
),
],
),
),
body: Center(
child: Container(
child: Text("This is a page blahblah"),
),
),
),
)
EDIT #2
Now , This code changes the Icon color, but leaves the text color change as default (You can customize the change for color of text like the icon color). Code:
import 'package:flutter/material.dart';
class FirstPage extends StatefulWidget {
@override
_FirstPageState createState() => _FirstPageState();
}
class _FirstPageState extends State<FirstPage> {
int _currentIndex = 0;
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
onTap: (index){
setState(() {
_currentIndex = index;
});
},
tabs: <Tab>[
Tab(
child: Row(
children: <Widget>[
Text("Select", textAlign: TextAlign.start,),
SizedBox(
width: 24.0,
),
Icon(
Icons.arrow_drop_down,
color: _currentIndex == 0 ? Colors.deepOrange : Colors.white54
),
],
),
),
Tab(
child: Row(
children: <Widget>[
Text("Select", textAlign: TextAlign.start,),
SizedBox(
width: 24.0,
),
Icon(
Icons.arrow_drop_down,
color: _currentIndex == 1 ? Colors.deepOrange : Colors.white54,
),
],
),
),
],
),
),
body: Center(
child: Container(
child: Text("This is a page blahblah"),
),
),
),
);
}
}
Related Topics
iPhone Camera, How to Avoid Cameraoverlay on Preivew View; How to Know When Entering Preview View
Ms Excel Type Spreadsheet Creation Using Objective-C for iOS App
Flutter: Disable Swipe to Navigate Back in iOS and Android
Ios: Usage of Self and Underscore(_) with Variable
How to Do Authorization and Login with Wechat Using the iOS Sdk
Why Is Uiwebview Cangoback=No in iOS7
How to Permanently Allow Usage of Camera on Trusted Websites with iOS - Safari
Running Nsurlsession Completion Handler on Main Thread
How to Display Uiview Over Keyboard in iOS
Universal Links Not Working on iOS10
How to Set the Rootviewcontroller with Swift, iOS 7
Cncopycurrentnetworkinfo with iOS 13
Sending Latitude and Longitude to Server When App Is in Background
Application Is "Ready to Sale" But Not Reflected on Itunes Store