Coder Social home page Coder Social logo

andy671 / dachshund-tab-layout Goto Github PK

View Code? Open in Web Editor NEW
858.0 20.0 93.0 164 KB

Extended Android Tab Layout with animated indicators that have continuous feedback.

License: MIT License

Java 100.00%
android-library android-ui android-development java animations android-layout android view

dachshund-tab-layout's People

Contributors

andy671 avatar luongvo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dachshund-tab-layout's Issues

Error in Using without Pager

How can i use this without pager.i tried to add tabs using addTab method and later tried using addOntabselected Listener but its showing an error.I am using below code to do so. Is there any other way of doing the same thing or is there something wrong with my code ?

DachshundTabLayout navigationTabStrip = (DachshundTabLayout) view.findViewById(R.id.tablayout);
    navigationTabStrip.addTab(new TabLayout.Tab().setText("Pug"),1,true);
    navigationTabStrip.addTab(new TabLayout.Tab().setText("Bulldog"),2);
    navigationTabStrip.addTab(new TabLayout.Tab().setText("Beagle"),3);

with a addontabselectedlistener

navigationTabStrip.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            Toast.makeText(getContext(), tab.getText(), Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });

its showing an error

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setContentDescription(java.lang.CharSequence)' on a null object reference
at com.google.android.material.tabs.TabLayout$Tab.setText(TabLayout.java:1846)

Not possible to set a custom animated indicator or select default ones programatically.

To reproduce:

  1. Import dachsund to a new empty project
  2. Add a DachsundTabLayout to the bottom of the main activity view with the following xml
    <com.kekstudio.dachshundtablayout.DachshundTabLayout
    android:id="@+id/homeTabLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBotomOf="parent"
    />
  3. In the MainActivity's onStart, onCreate or onResume call setAnimatedIndicator(new LineMoveIndicator(dachsundTabLayout))
  4. Run the app

Expected:
App uses LineMoveIndicator once it runs

Actual:
App uses the default DachshundIndicator

Problem, the way I understand it:
setupAnimatedIndicator should not overule an AnimatedIndicator set through setAnimatedIndicator.

When animatedIndicator is set programatically by calling setAnimatedIndicator in the Android Activity's onCreate, onStart or onResume methods the setupAnimatedIndicator is still called afterwards and the programatically set indicator with either default or whatever was set through xml.

A potential quick fix could be to add a CUSTOM flag for the animatedIndicatorType that could be both set from xml and would be automatically used once setAnimatedIndicator has been called.

Disable TabLayout On Click

I'm using the new class provided by the design library : TabLayout. And I want in specific cases that the one I'm using can't change tab anymore.
I manage to disable swipe on its viewpager but I can't figure out how to disable the change of page by clicking on tabs.
Thank's in advance.

**In The Normal Tablayout with below code i can disable it **

LinearLayout tabStrip = ((LinearLayout)mTabLayout.getChildAt(0)); for(int i = 0; i < tabStrip.getChildCount(); i++) { tabStrip.getChildAt(i).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); }

But in This Library How Can I Do It ?

width of the indicator

two tabs in my tablayout,
how should I makes the both tab's width containing the half width of screen width?
what about tree tabs ?

java.lang.NoSuchMethodErro

hello andy671
I use it with an error
what is the solution
error:

Process: com.example.ganger.dmzjapp, PID: 24343
                                                                            java.lang.NoSuchMethodError: No super method setupWithViewPager(Landroid/support/v4/view/ViewPager;Z)V in class Landroid/support/design/widget/TabLayout; or its super classes (declaration of 'android.support.design.widget.TabLayout' appears in /data/data/com.example.ganger.dmzjapp/files/instant-run/dex/slice-com.android.support-design-23.3.0_885fe9c4b8444b33318faa2144462abf1840cd46-classes.dex)
                                                                                at com.kekstudio.dachshundtablayout.DachshundTabLayout.setupWithViewPager(DachshundTabLayout.java:122)
                                                                                at com.kekstudio.dachshundtablayout.DachshundTabLayout.setupWithViewPager(DachshundTabLayout.java:117)
                                                                                at com.example.ganger.dmzjapp.MainActivity.onCreate(MainActivity.java:158)
                                                                                at android.app.Activity.performCreate(Activity.java:6237)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:148)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

code:

 pageAdapter=new MyPageAdapter(getSupportFragmentManager(),titles,fs);
        viewPager.setAdapter(pageAdapter);

        dachshundTabLayout= (DachshundTabLayout) findViewById(R.id.tab_layout);
        dachshundTabLayout.setupWithViewPager(viewPager);

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.