0

i'm trying to get a custom tab bar working on different screens and just saw a weird thing.

Trying on two HTC phones, the Legend and the new One X.

tab layout is in its own file (tab_indicator.xml) , looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:layout_marginBottom="0dp"
android:orientation="vertical"

android:background="@drawable/tab_indicator"
android:padding="3dp">

<ImageView android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:src="@drawable/icon"

/> 

<TextView android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="11dp"
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="0dp"
    style="?android:attr/tabWidgetStyle"
/>    

Now, my problem is the "layout_height"!

On the Legend, this works fine, my icons appear with some space under them before the text shows.

On the One X, however, the bar actually looks smaller and the text clashes into the icons, i.e. the height seems to small!

I would have expected the other way around since the screen is much larger on the One x...

if anybody has any thoughts, i'd appreciate it.

Mathias
  • 3,879
  • 5
  • 36
  • 48
  • The problem is the Legend has a much smaller resolution (180 ppi) than the One X (312 ppi). I'm not a Java/Android programmer, but is there a way to specify the height based on ratio to the screen? – benjer3 Jun 13 '12 at 08:47
  • Here we go: try [this](http://stackoverflow.com/questions/2025282/difference-of-px-dp-dip-and-sp-in-android). Basically, I think you need to change your text size to `"11sp"`. – benjer3 Jun 13 '12 at 09:19
  • @Benjer, i don't think so. I dont use sp since it then will depend on the users font settings, which can totally mess up my layout. – Mathias Jun 13 '12 at 20:01
  • Okay. Again, not an Android programmer. Hopefully someone posts an answer. – benjer3 Jun 13 '12 at 21:10

0 Answers0