0

I have a tabLayout where main.xml:

<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
    <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    </FrameLayout>
</LinearLayout>
</TabHost>

And the tab in question:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
    >
<TextView
        android:id="@+id/if1"
        android:text="@string/aText"
        android:gravity="center_horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="3"
        android:visibility="visible"/>

<ImageView
        android:id="@+id/id2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="visible"
        android:src="@drawable/sample"
        android:layout_weight="1"

        />

<android.widget.RatingBar android:id="@+id/ratingBar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:numStars="5"
                          android:stepSize="1"
                          android:visibility="visible"
        />

<android.widget.Button android:id="@+id/rateButton"
                       android:text="@string/rateButton"
                       android:layout_width="fill_parent"
                       android:layout_height="wrap_content"
                       android:visibility="invisible"
        />
</LinearLayout>

Why does the RatingBar show up like this on my Samsung Galaxy S running Android 2.3.6? It looks ok in the emulator.

enter image description here

DagR
  • 2,900
  • 3
  • 24
  • 36

1 Answers1

0

Why does the RatingBar show up like this on my Samsung Galaxy S running Android 2.3.6?

Because you have not given it enough screen space. You are only giving it a percentage of screen space, and based upon the device resolution and the data, that is not enough room.

You should not be relying upon android:layout_weight to help you for things that are supposed to always be completely visible. android:layout_weight works great with things that are intrinsically scrollable (e.g., ListView), as they can adapt to whatever size is needed.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ok, thanks, so RatingBar simply doesn't fit on my screen? I thought I could somehow make it resize to fit the screen. I guess I'll have to use smaller star images then. – DagR Apr 30 '12 at 05:00