1

The "First" image shows a dialog created using an XML layout that seems to function OK.

If the tablet goes into "hibernate", after the tablet is activated again the screen image then looks like the "Second" image.

Why does the layout change when entering/leaving hibernation.

The layout file is :

    <TableRow android:id="@+id/tableRow2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginBottom="3dp" >
        <TextView android:id="@+id/textView3" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" android:layout_marginRight="10dp" 
            android:text="Concept" 
            android:layout_weight="1"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:background="@drawable/rectanglewhite"
            android:textColor="#000000" 
            android:gravity="right"/>
        <TextView 
            android:id="@+id/tvsctconcept" android:layout_width="wrap_content" android:layout_height="wrap_content" 
            android:layout_weight="11" 
            android:text="" 
            android:textAppearance="?android:attr/textAppearanceMedium"/>            
    </TableRow>
    <TableRow android:id="@+id/tableRow3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginBottom="3dp" >
        <TextView android:id="@+id/textView3" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_marginRight="10dp" 
            android:text="PT" 
            android:layout_weight="1" 
            android:textAppearance="?android:attr/textAppearanceMedium" 
            android:background="@drawable/rectanglepurple"
            android:textColor="#000000"
            android:gravity="right"/>
        <TextView 
            android:id="@+id/tvsctpt" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="" 
            android:layout_weight="11"
            android:textAppearance="?android:attr/textAppearanceMedium"/>            
    </TableRow>
    <TableRow android:id="@+id/tableRow4" 
        android:layout_height="wrap_content"
        android:layout_marginBottom="3dp" >
        <TextView android:id="@+id/textView3" 
            android:layout_width="50dp" 
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:text="FSN" 
            android:layout_weight="1" 
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:background="@drawable/rectanglebg2" 
            android:textColor="#000000"
            android:gravity="right" />
        <TextView 
            android:id="@+id/tvsctfsn" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="" 

            android:layout_weight="11"
            android:textAppearance="?android:attr/textAppearanceMedium"/>            
    </TableRow>
</TableLayout>

Before After

1 Answer 1

2

You're using wrap_content on the views width. when the xml is first rendered, it's not measuring against any content. After waking up there are values in those textviews, and so they are wrapped to that content. You should set the width to a specific value or match_parent.

1
  • Thanks David makes perfect sense how you've explained it. Oct 11, 2012 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.