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 3810176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:25:11+00:00 2026-05-19T15:25:11+00:00

I implemented tablayout but it is not working properly in emulator. The height is

  • 0

I implemented tablayout but it is not working properly in emulator. The height is not showing properly in device. Can anybody tell me what the problem is?

this is my layout file

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

 <TabHost 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:background="@color/black"
        > 
   <RelativeLayout    
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent"> 
         <FrameLayout android:id="@android:id/tabcontent" 
             android:layout_width="fill_parent"  
             android:layout_height="wrap_content" 
             android:layout_alignParentTop="true"  
             android:layout_above="@android:id/tabs" /> 
    <TabWidget android:id="@android:id/tabs" 
             android:layout_width="fill_parent"  
             android:layout_height="wrap_content" 
              android:layout_alignParentBottom="true"
                       /> 
          </RelativeLayout> 
    </TabHost>
    </LinearLayout>

this is my java code setting height and width

for (int i =0; i<tabWidget.getChildCount(); i++) {
         //tabWidget.getChildAt(i).setBackgroundColor(R.color.black);
          tabWidget.getChildAt(i).getLayoutParams().height = height;
   tabWidget.getChildAt(i).getLayoutParams().width = width;
   RelativeLayout relLayout = (RelativeLayout)tabWidget.getChildAt(i); 
   TextView tv = (TextView)relLayout.getChildAt(1); 
   tv.setTextSize(10.0f);
   tv.setTypeface(myTypeface1);
}

Can anybody tell me how to set height and width for tab bar? Give sample code

Thanks

  • 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-05-19T15:25:11+00:00Added an answer on May 19, 2026 at 3:25 pm

    This is probably related to the difference in screen density between the emulator and your device. Check out DisplayMetrics – you need to get the density of the current device as follows:

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    float density = metrics.density;
    

    Next, calculate the necessary height and width scaling factor according to the section on density independent pixels on the Android dev site:

    float scaling_factor = density / 160;

    Finally, set your widget’s height and width appropriately:

    tabWidget.getChildAt(i).getLayoutParams().height = int ( height * scaling_factor );
    tabWidget.getChildAt(i).getLayoutParams().width = int ( width * scaling_factor );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented an rpc call. It works on local machine but does not work
I implemented a small OOP library in Lua, and two things are not quite
Having implemented CLogClass to make decent logging I also defined macro, but it works
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
i implemented a small code to show pictures, but why is the picture on
I implemented a ImageCache. But I'm curious about what type to store in it
I implemented the GPS in my app, in one Activity like this: LocationManager mlocManager
I implemented the following Silverlight app after seeing this instructions , here's my code:
I implemented a custom list view, but now there's no visual feedback that an
i implemented an application for iPhone, i just wanted to know that can i

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.