Custom styling of com.google.android.material.tabs.TabLayout
up vote
1
down vote
favorite
I am using the new Google Material Components for Android
Currently, I am trying to give a custom look for Tablayout (com.google.android.material.tabs.TabLayout).
I have created a style as follows:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
</style>
However, upon applying this theme, the tab indicator becomes invisible.
Without theme:
With theme:
Also, I tried other things like changing tabIndicatorColor and still not working!
How do I fix this? Which is the correct way to change the colors/theme of Material Components?
android material-design material-ui material material-components-android
add a comment |
up vote
1
down vote
favorite
I am using the new Google Material Components for Android
Currently, I am trying to give a custom look for Tablayout (com.google.android.material.tabs.TabLayout).
I have created a style as follows:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
</style>
However, upon applying this theme, the tab indicator becomes invisible.
Without theme:
With theme:
Also, I tried other things like changing tabIndicatorColor and still not working!
How do I fix this? Which is the correct way to change the colors/theme of Material Components?
android material-design material-ui material material-components-android
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am using the new Google Material Components for Android
Currently, I am trying to give a custom look for Tablayout (com.google.android.material.tabs.TabLayout).
I have created a style as follows:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
</style>
However, upon applying this theme, the tab indicator becomes invisible.
Without theme:
With theme:
Also, I tried other things like changing tabIndicatorColor and still not working!
How do I fix this? Which is the correct way to change the colors/theme of Material Components?
android material-design material-ui material material-components-android
I am using the new Google Material Components for Android
Currently, I am trying to give a custom look for Tablayout (com.google.android.material.tabs.TabLayout).
I have created a style as follows:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
</style>
However, upon applying this theme, the tab indicator becomes invisible.
Without theme:
With theme:
Also, I tried other things like changing tabIndicatorColor and still not working!
How do I fix this? Which is the correct way to change the colors/theme of Material Components?
android material-design material-ui material material-components-android
android material-design material-ui material material-components-android
edited Nov 10 at 11:17
asked Nov 10 at 11:11
0n4li
12210
12210
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
With these changes, it works as expected:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:tabGravity="fill"
app:tabTextAppearance="@style/customFontStyle">
//Tab items maybe
</com.google.android.material.tabs.TabLayout>
Styles.xml:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
<item name="tabIndicatorColor">@color/yourcolor</item>
</style>
Result:
1
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
With these changes, it works as expected:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:tabGravity="fill"
app:tabTextAppearance="@style/customFontStyle">
//Tab items maybe
</com.google.android.material.tabs.TabLayout>
Styles.xml:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
<item name="tabIndicatorColor">@color/yourcolor</item>
</style>
Result:
1
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
add a comment |
up vote
0
down vote
accepted
With these changes, it works as expected:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:tabGravity="fill"
app:tabTextAppearance="@style/customFontStyle">
//Tab items maybe
</com.google.android.material.tabs.TabLayout>
Styles.xml:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
<item name="tabIndicatorColor">@color/yourcolor</item>
</style>
Result:
1
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
With these changes, it works as expected:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:tabGravity="fill"
app:tabTextAppearance="@style/customFontStyle">
//Tab items maybe
</com.google.android.material.tabs.TabLayout>
Styles.xml:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
<item name="tabIndicatorColor">@color/yourcolor</item>
</style>
Result:
With these changes, it works as expected:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:tabGravity="fill"
app:tabTextAppearance="@style/customFontStyle">
//Tab items maybe
</com.google.android.material.tabs.TabLayout>
Styles.xml:
<style name="AppTheme.TabLayout" parent="Widget.MaterialComponents.TabLayout">
<item name="android:background">@color/colorPrimary</item>
<item name="tabIndicatorColor">@color/yourcolor</item>
</style>
Result:
answered Nov 10 at 11:32
Mohsen
9,83742470
9,83742470
1
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
add a comment |
1
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
1
1
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
I was using android:theme instead of style and that's what caused the issue!
– 0n4li
Nov 10 at 12:05
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238360%2fcustom-styling-of-com-google-android-material-tabs-tablayout%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password