2012-10-11 3 views
1

«Первое» изображение показывает диалог, созданный с использованием макета XML, который, кажется, работает нормально.Проблемы с макетом Android после «Hibernate»

Если планшет переходит в «спящий режим», после того, как планшет снова активирован, изображение на экране выглядит как «второе» изображение.

Почему макет изменяется при входе/выходе из спящего режима.

Файл макета:

<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

ответ

2

Вы используете wrap_content на мнения ширины. когда xml сначала отображается, он не измеряет никакого содержимого. После пробуждения есть значения в этих textview s, и поэтому они завернуты в этот контент. Вы должны установить ширину для определенного значения или match_parent.

+0

Спасибо, Дэвид прекрасно понимает, как вы это объяснили. –

+1

приятный информация. +1 –

Смежные вопросы