title: Android tab layout - change size
body: <p>I am designing an app with a tablyout. My design looks fine on big screen devices, but on fx. HTC Wildfire, the tab fills almost 1/3 of the screen.</p>
  
  <p>If i make a smaller tab on the layout file for small screen devices, my image will disappear.
  My activity looks like this:</p>
  
  <pre><code>    package dk.appsfabrikken.iphonetabs;
  import dk.appsfabrikken.iphonetabs.R;
  import android.app.TabActivity;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Color;
  import android.graphics.drawable.StateListDrawable;
  import android.os.Bundle;
  import android.view.Gravity;
  import android.view.ViewGroup.LayoutParams;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.TabHost;
  import android.widget.TextView;
  
  public class MainActivity extends TabActivity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
  
          setContentView(R.layout.main);
  
          TabHost tabHost = getTabHost();
          TabHost.TabSpec spec;
          Intent intent;
          MyView view = null;
  
          // Information Tab
          intent = new Intent().setClass(this, InfoActivity.class);
          view = new MyView(this, R.drawable.icon, R.drawable.icon, "Information");
          view.setBackgroundDrawable(this.getResources().getDrawable(R.layout.selecttabbackground));
          spec = tabHost.newTabSpec("Information").setIndicator(view).setContent(intent);
          tabHost.addTab(spec);
  
          // Pris tab
          intent = new Intent().setClass(this, PriceActivity.class);
          view = new MyView(this, R.drawable.icon, R.drawable.icon, "Priser");
          view.setBackgroundDrawable(this.getResources().getDrawable(R.layout.selecttabbackground));
          spec = tabHost.newTabSpec("Priser").setIndicator(view).setContent(intent);
          tabHost.addTab(spec);
  
          // Produkt liste Tab
          intent = new Intent().setClass(this, ListeActivity.class);
          view = new MyView(this, R.drawable.icon, R.drawable.icon, "Apps");
          view.setBackgroundDrawable(this.getResources().getDrawable(R.layout.selecttabbackground));
          spec = tabHost.newTabSpec("Apps").setIndicator(view).setContent(intent);
          tabHost.addTab(spec);
  
          //Kontakt tab
          intent = new Intent().setClass(this, ContactActivity.class);
          view = new MyView(this, R.drawable.icon, R.drawable.icon, "Kontakt");
          view.setFocusable(true);
          view.setBackgroundDrawable(this.getResources().getDrawable(R.layout.selecttabbackground));
          spec = tabHost.newTabSpec("Kontakt").setIndicator(view).setContent(intent);
          tabHost.addTab(spec);
  
          tabHost.setCurrentTab(0);
          tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = LayoutParams.WRAP_CONTENT;
          tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = LayoutParams.WRAP_CONTENT;
          tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = LayoutParams.WRAP_CONTENT;
          tabHost.getTabWidget().getChildAt(3).getLayoutParams().height = LayoutParams.WRAP_CONTENT;
  
      }
  
      private class MyView extends LinearLayout {
          ImageView iv;
          TextView tv;
  
          public MyView(Context c, int drawable, int drawableselec, String label) {
              super(c);
              iv = new ImageView(c);
              StateListDrawable listDrawable = new StateListDrawable();
              listDrawable.addState(SELECTED_STATE_SET, this.getResources()
                      .getDrawable(drawableselec));
              listDrawable.addState(ENABLED_STATE_SET, this.getResources()
                      .getDrawable(drawable));
              iv.setImageDrawable(listDrawable);
              iv.setBackgroundColor(Color.TRANSPARENT);
              iv.setLayoutParams(new LayoutParams(50, 50, (float) 0.0));
              setGravity(Gravity.CENTER);
              tv = new TextView(c);
              tv.setText(label);
              tv.setGravity(Gravity.CENTER);
              tv.setBackgroundColor(Color.TRANSPARENT);
              tv.setTextColor(Color.WHITE);
              tv.setTextSize(12);
              tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                      LayoutParams.WRAP_CONTENT, (float) 1.0));
              setOrientation(LinearLayout.VERTICAL);
              addView(iv);
              addView(tv);
              setBackgroundDrawable(this.getResources().getDrawable(
                      R.layout.selecttabbackground));
          }
      }
  }
  </code></pre>
  
  <p>Is there any way to test on the screen size of the device inside the activity, and then change the <code>iv.setLayoutParams(new LayoutParams(50, 50, (float) 0.0));</code> and make the images smaller?</p>
  
  <p>If you don't understand my point, I will try to explain it better.</p>