GithubHelp home page GithubHelp logo

Change Tab highlight about smarttablayout HOT 3 CLOSED

ogaclejapan avatar ogaclejapan commented on September 22, 2024
Change Tab highlight

from smarttablayout.

Comments (3)

ShkurtiA avatar ShkurtiA commented on September 22, 2024

Hello,
I had the same problem because I am using this library but not with a ViewPager. I also needed to remove that click so I have customized the library. To fix that error inside SmartTabLayout at method populateTextTabStrip I added at line 364:
tabView.setBackgroundColor(tabView.getResources().getColor(android.R.color.transparent));
so that I can override the default click selector.

from smarttablayout.

ogaclejapan avatar ogaclejapan commented on September 22, 2024

Hi, @denebasecas @ShkurtiA

In the current version must define the layout of the custom tab.

res/drawable/tab_background_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/your_highlight_color"/>
        </shape>
    </item>
    <item android:drawable="@color/your_normal_color"/>
</selector>

res/layout/custom_tab.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/custom_text"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:textSize="14sp"
    android:textColor="@color/your_tab_text_color"
    android:gravity="center"
    android:paddingLeft="24dp"
    android:paddingRight="24dp"
    android:background="@drawable/tab_background_selector"
    >

</TextView>

res/layout/your_layout.xml

...

<com.ogaclejapan.smarttablayout.SmartTabLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@id/viewpagertab"
    android:layout_width="match_parent"
    android:layout_height="@dimen/tab_height"
    ...
    app:stl_customTabTextLayoutId="@layout/custom_tab"
    app:stl_customTabTextViewId="@id/custom_text"
    />

...

Try implemented in the next version so that it can be easily specified in the attributes of SmartTabLayout πŸ‘

from smarttablayout.

ogaclejapan avatar ogaclejapan commented on September 22, 2024

Hi, @denebasecas @ShkurtiA
Right now, released the 1.1.3 πŸ‘

res/layout/your_layout.xml

...

<com.ogaclejapan.smarttablayout.SmartTabLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@id/viewpagertab"
    android:layout_width="match_parent"
    android:layout_height="@dimen/tab_height"
    ...
    app:stl_defaultTabBackground="@drawable/your_tab_background_selector"
    />

...

from smarttablayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.