Issue
Please, tell me
First of all in drawable I make selector
tab_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/tab_background_selected"
android:state_selected="true" />
<item
android:drawable="@drawable/tab_background_unselected"
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false" />
</selector>
for active tab tab_background_selected.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FFFFFF" />
</shape>
for pasive tab tab_background_unselected.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#000000" />
</shape>
and in styles
<style name="@style/AppTheme.TabLayout" parent="android:Widget">
<item name="tabBackground">@drawable/tab_background</item>
</style>
What I must do than? in Tablelayout? or something alse?
app:tabTextAppearance="@style/AppTheme.TabLayout"
Solution
In your Xml file on which you are using TabLayout
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabSelectedTextColor="@color/colorAccent"
app:tabBackground="@color/tab_color"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabTextColor="@color/toggle_normal_off">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your First Text" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Second Text" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Third Text" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Fourth Text" />
</android.support.design.widget.TabLayout>
This might help you!!!
Answered By - Parth Lotia
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.