2012-02-29 54 views
3

我有一个奇怪的问题。我的应用程序在Android 2.3.4上完美运行在我的三星Galaxy II S上。在我的Android 3.0平板电脑上出现了一个奇怪的行为:视图中的灰色背景颜色尽管白色背景定义并且首先工作

背景颜色,显式设置为白色突然是不同的灰色。

  • 我有两个受影响的活动,一个WebView有点复杂,另一个只有4个按钮非常简单。他们都有明确的白色作为他们的LinearLayout,ScrollView,TextViews等的背景
  • 应用程序启动,一切正常,背景是白色的
  • 我来回切换到复杂的活动,一段时间后背景不再是白色,而是以不同的灰色调。在那之后,他们仍然灰色,也为与4个按钮的简单的活动
  • 我不改变代码的背景颜色

以下几点可能导致这种行为:

  • 使用WebView。它不使用所有的时间,似乎这种行为occours更快/只有在WebView中可见
  • 改变orieantation似乎推动这一行为

我迄今为止尝试:

  • 禁用硬件accelaration
  • 力重绘
  • 试图重新排列在复杂的活动的意见,使他们不重叠摆脱警告的“第一布局后无法获得viewWidth”

对我来说,这似乎是一种可视化调试模式,但我还没有发现任何关于这种模式的网络。

大概是唯一提示: 我得到一个警告:第一个布局

代码为根本活动

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/white" 
android:orientation="vertical" > 

<Button 
    android:id="@+id/ag_btn_pressespiegel" 
    android:text="@string/artikelgruppen_pressespiegelbutton" 
    android:layout_width="fill_parent" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="16dp" 
    android:textColor="@color/black" 
    android:layout_marginBottom="16dp" /> 

<Button 
    android:id="@+id/ag_btn_dossier" 
    android:text="@string/artikelgruppen_dossierbutton" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textColor="@color/black" 
    android:layout_marginBottom="16dp" /> 

<Button 
    android:id="@+id/ag_btn_tag" 
    android:text="@string/artikelgruppen_tagbutton" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textColor="@color/black" 
    android:layout_marginBottom="32dp" /> 

<Button 
    android:id="@+id/ag_btn_sync" 
    android:text="@string/artikelgruppen_syncbutton" 
    android:layout_marginLeft="8dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textColor="@color/black" 
    android:layout_marginBottom="16dp" /> 

</LinearLayout> 

代码与WebView中

的compley活动后无法获得viewWidth
<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/ad_sv_artikeldetails" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/white" > 

<RelativeLayout 
    android:id="@+id/ad_rl_artikeldetails" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/white" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="100dp" 
     android:background="@color/white" > 

     <ImageView 
      android:id="@+id/ad_img_kanal" 
      android:layout_width="32dp" 
      android:layout_height="32dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginLeft="5dp" 
      android:layout_marginTop="5dp" > 
     </ImageView> 

     <ImageView 
      android:id="@+id/ad_img_pdf" 
      android:layout_width="24dp" 
      android:layout_height="16dp" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="6dp" 
      android:layout_marginTop="54dp" 
      android:src="@drawable/pdfdocument" > 
     </ImageView> 

     <ImageView 
      android:id="@+id/ad_img_land" 
      android:layout_width="16dp" 
      android:layout_height="16dp" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="4dp" 
      android:layout_marginTop="5dp" > 
     </ImageView> 

     <TextView 
      android:id="@+id/ad_txt_medie" 
      android:layout_width="wrap_content" 
      android:layout_height="24dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginLeft="43dp" 
      android:layout_marginRight="120dp" 
      android:layout_marginTop="22dp" 
      android:maxLines="1" 
      android:background="@color/white" 
      android:textColor="@color/black" > 
     </TextView> 

     <TextView 
      android:id="@+id/ad_txt_datum" 
      android:layout_width="wrap_content" 
      android:layout_height="16dp" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="6dp" 
      android:background="@color/white" 
      android:layout_marginTop="22dp" > 
     </TextView> 
    </RelativeLayout> 

    <!-- Titel & Grosses Linarlayout für vertikale Anordnung --> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="80dp" 
     android:background="@color/white" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/ad_txt_titel" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="35dp" 
      android:layout_marginTop="0dp" 
      android:background="@color/white" 
      android:maxLines="2" 
      android:textColor="@color/black" 
      android:textStyle="bold" > 
     </TextView> 

     <TextView 
      android:id="@+id/ad_txt_text" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="18dp" 
      android:background="@color/white" 
      android:textColor="@color/black" > 
     </TextView> 

     <WebView 
      android:id="@+id/ad_web_html" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="0dp" 
      android:layout_marginRight="12dp" 
      android:layout_marginTop="18dp" 
      android:background="@color/white" 
      android:clickable="false" > 
     </WebView> 

     <!-- Thema --> 

     <LinearLayout 
      android:id="@+id/ad_ll_thema" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="18dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_thema_label" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="5dp" 
       android:layout_marginTop="0dp" 
       android:background="@color/white" 
       android:text="@string/artikeldetail_thema" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_thema" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="0dp" 
       android:layout_marginRight="12dp" 
       android:background="@color/white" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 

     <!-- Suchbegriff --> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/ad_ll_suchbegriff" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_suchbegriff_label" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="5dp" 
       android:layout_marginTop="0dp" 
       android:background="@color/white" 
       android:text="@string/artikeldetail_suchbegriff" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_suchbegriff" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginRight="12dp" 
       android:background="@color/white" 
       android:layout_marginTop="0dp" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 

     <!-- Liefer & Ausgabedatum --> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/ad_ll_lieferdatum" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="18dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_lieferung" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="5dp" 
       android:layout_marginTop="0dp" 
       android:background="@color/white" 
       android:text="@string/artikeldetail_lieferdatumlieferung" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_lieferung_datum" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="0dp" 
       android:layout_marginRight="12dp" 
       android:background="@color/white" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/ad_ll_ausgabedatum" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_ausgabe" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="5dp" 
       android:background="@color/white" 
       android:layout_marginTop="0dp" 
       android:text="@string/artikeldetail_ausgabedatum" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_ausgabe_datum" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@color/white" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="0dp" 
       android:layout_marginRight="12dp" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/ad_ll_medienart" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="18dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_lieferung" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:background="@color/white" 
       android:layout_marginLeft="5dp" 
       android:layout_marginTop="0dp" 
       android:text="@string/artikeldetail_medienart" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_medienart" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@color/white" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="0dp" 
       android:layout_marginRight="12dp" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/ad_ll_medientyp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_ausgabe" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:background="@color/white" 
       android:layout_marginLeft="5dp" 
       android:layout_marginTop="0dp" 
       android:text="@string/artikeldetail_medietyp" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_medietyp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@color/white" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="0dp" 
       android:layout_marginRight="12dp" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/ad_ll_kategorien" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="18dp" 
      android:background="@color/white" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/ad_txt_kategorien_label" 
       android:layout_width="120dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:background="@color/white" 
       android:layout_marginLeft="5dp" 
       android:layout_marginTop="0dp" 
       android:text="@string/artikeldetail_kategorien" 
       android:textColor="@color/black" > 
      </TextView> 

      <TextView 
       android:id="@+id/ad_txt_kategorien" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@color/white" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="0dp" 
       android:layout_marginRight="12dp" 
       android:textColor="@color/black" > 
      </TextView> 
     </LinearLayout> 
    </LinearLayout> 
</RelativeLayout> 
</ScrollView> 

链接结合复杂的活动与不正确的灰色背景(左),正确的白色背景(正确的网站)复杂的活动截图:http://int.argus.ch/screenshots.jpg

视频链接这表明改变方向导致的问题(在另一个活动)(相当大的50MB):http://int.argus.ch/grey.mp4

我不能发布链接到简单的活动截图这里,是因为我是一个新手,但LinearLayout的背景颜色不再是白色,而且也是灰色的。

PS:我将@white定义更改为蓝色。一切都很蓝。如果问题发生,一切都是灰色的,没有不同的蓝色!

提前感谢

回答

0

你可以尝试使用这种固体(此为白)色的背景

android:cacheColorHint="#ffffffff" 

如果您使用的是绘制作为背景,请尝试使用此

android:cacheColorHint="#00000000" 

让我知道这是否可行

+0

不幸的是,它并没有LP。我向所有相关的LinearLayout等添加了cacheColorHint(#ffffffff)(尤其是因为简单的活动只有一个带有4个按钮的LinearLayout),并且它们仍然变成灰色。 – 2012-02-29 11:43:49