Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7732409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:43:24+00:00 2026-06-01T06:43:24+00:00

Is it possible to change Android Tabs that if you press one, it comes

  • 0

Is it possible to change Android Tabs that if you press one, it comes to the center of the TabHost. Only 3 Tabs are visible, doesn’t matter how many there are. Like in the Android 4.0 Google Music App!
If it is, how would you do that?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:43:26+00:00Added an answer on June 1, 2026 at 6:43 am

    I did find the answer myself.
    If somebody else needs it, this should do it:

        final HorizontalScrollView mHorizontalScrollView;
        float scale = getResources().getDisplayMetrics().density;
        final double tabWidth = (int) (150 * scale + 0.5f);
    
        for (int i = 0; i < tabHost.getTabWidget().getTabCount(); i++) {
            tabHost.getTabWidget().getChildTabViewAt(i).getLayoutParams().width = (int) tabWidth;
        }
    
        final double screenWidth = getWindowManager().getDefaultDisplay()
                .getWidth();
        mHorizontalScrollView = (HorizontalScrollView) findViewById(R.id.hscrollview);
    
        tabHost.setOnTabChangedListener(new OnTabChangeListener() {
    
            @Override
            public void onTabChanged(String tabId) {
                int nrOfShownCompleteTabs = ((int) (Math.floor(screenWidth
                        / tabWidth) - 1) / 2) * 2;
                int remainingSpace = (int) ((screenWidth - tabWidth - (tabWidth * nrOfShownCompleteTabs)) / 2);
    
                int a = (int) (tabHost.getCurrentTab() * tabWidth);
                int b = (int) ((int) (nrOfShownCompleteTabs / 2) * tabWidth);
                int offset = (a - b) - remainingSpace;
    
                mHorizontalScrollView.scrollTo(offset, 0);
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create an android app that is able to change pre-installed
Is it possible on android that we change the displayed things on screen, out
I have an Android application with a main activity that is the tabhost. I'm
Is it possible to change the source for android MediaRecorder? I would like to
Does anyone know is it possible to change android market publish account with other
Possible Duplicate: Change language programatically in Android I would like to develop an Android
Is it possible to change the value of the android:noHistory attribute of an Activity
Is it possible in android to change the look of the map like in
I know that it is possible to place the tabs at the top or
Is it possible to programmatically change the android:name attribute in code for Application and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.