0

I set an image for each tab and result is as expected but on some devices (tablets or some smartphone models) image is seen bigger and above text. How to solve it? Thank you.

activity,

        StateListDrawable selector = new StateListDrawable();

        selector.addState(new int[] { android.R.attr.state_selected }, dSel);

        icon.setImageDrawable(selector);

layout,

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

      <RelativeLayout       
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


        <LinearLayout  
            android:orientation="vertical"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:layout_below="@+id/mainLayout">

            <FrameLayout 
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" 
                android:layout_height="0dip"
                android:layout_weight="1" 
                android:scrollbars="none"
                android:isScrollContainer="false">
            </FrameLayout>

            <TabWidget 
                android:id="@android:id/tabs"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:layout_weight="0"
                />

        </LinearLayout>         

    </RelativeLayout>

enter image description hereenter image description here

Jaume
  • 3,672
  • 19
  • 60
  • 119
  • Have images specific to the resolution in your various drawable folders. – Swayam Jul 12 '12 at 09:18
  • ummm No! I should generate then different resolutions for each density, isn't it? if yes, could you please tell me optimus image sizes for each density? – Jaume Jul 12 '12 at 09:24
  • And well, if you create a new Project in Eclipse you would see that icons are added to the drawable folders by default. I recommend you use those sizes only. – Swayam Jul 12 '12 at 09:41
  • xhdpi-96X96, hdpi-72X72, mdpi-48X48, ldpi-36X36 – Swayam Jul 12 '12 at 09:43

1 Answers1

0

I believe these links would guide you properly to solve your problem.

http://developer.android.com/guide/practices/screens_support.html

http://coding.smashingmagazine.com/2011/06/30/designing-for-android/

http://www.coronalabs.com/blog/2011/01/27/dynamic-image-resolution-made-easy/

Plus, this question raises a problem similar to yours I believe.

Determining image sizes for multiple android screen sizes/densities

Community
  • 1
  • 1
Swayam
  • 16,294
  • 14
  • 64
  • 102