2013-04-30 75 views
2

我不知道为什么,当一个EditText被聚焦,然后布局滚动我的“表格”活动闪烁。 这只发生在Android 4.0 + 设备中我正在使用Table Layout并动态添加TableRow。用的EditText的Android形式使得屏幕闪烁

我的TableRow是这样的:

<TableRow xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tableRow1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/borda" 
    android:layout_margin="10dip" 
    android:paddingLeft="10dip" 
    > 
    <LinearLayout 
    android:id="@+id/l1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_marginTop="15dip" 
    android:layout_marginBottom="15dip" 
    > 

    <TextView 
     android:id="@+id/label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/nome" 
     android:textStyle="bold" 
     android:textColor="#526691" 
     android:textSize="15sp" 
     android:paddingLeft="10dip" 
     android:paddingRight="5dip" 
     /> 


     <EditText 
     android:id="@+id/valorLabel" 
     android:layout_width="140dip" 
     android:layout_height="wrap_content" 
     android:textSize="15sp" 
     android:background="#ffffffff" 
     android:singleLine="true" 
     android:inputType="textCapSentences" 
     android:textColor="#777777" />   


</LinearLayout> 

</TableRow> 

然后,我加的TableRow到TableLayout ....

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:cacheColorHint="#00000000"  
android:background="#dddddd"> 
<TextView 
     android:id="@+id/add_instancia_tv1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/add_fornecedor_informacoes" 
     android:textColor="#4c566c" 
     android:textStyle="bold" 
     android:paddingLeft="20dip" 
     android:paddingTop="20dip" 
     android:textSize="20dip"/> 
<TableLayout 
android:layout_width="fill_parent" 
android:id="@+id/table_novo_registro1" 
android:layout_height="wrap_content"  
android:orientation="vertical" 
android:background="#dddddd" > 
... 

然后,在代码中,我吹我的TableRow

TableRow colunaNome= (TableRow) getLayoutInflater().inflate(R.layout.tablerownovocampo, null); 
      LinearLayout linearlNome= (LinearLayout)colunaNome.getChildAt(0); 
      TextView textvNome=(TextView)linearlNome.getChildAt(0); 
      textvNome.setText(R.string.nome); 
      etNome=(EditText)linearlNome.getChildAt(1); 

和很多的TableRow的加入。

问题是...

为什么我的表格闪烁(闪烁),当我滚动呢?为什么只有在Android 4.0 +中才会发生?

我已经看到这篇文章.... http://android-developers.blogspot.com.br/2009/01/why-is-my-list-black-android.html 但我没有使用ListView。

心中已经尝试过

android:cacheColorHint="#00000000" 

在TableLayout,但没有奏效。

回答

0

这将100%工作.....

滚动型SV =(滚动型)findViewById(R.id.scrollView1);

sv.setOnTouchListener(new OnTouchListener() { 

     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      edttext.clearFocus(); 
      return false; 
     } 
    });