【问题标题】:Android Form with EditText makes the screen flash带有 EditText 的 Android Form 使屏幕闪烁
【发布时间】:2013-04-23 23:31:21
【问题描述】:

我不知道为什么我的“表单”活动在 EditText 被聚焦然后滚动布局时闪烁。 它只发生在 Android 4.0 + 的设备上 我正在使用表格布局并动态添加 TableRow。

我的 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 中,但它不起作用。

【问题讨论】:

    标签: android-layout android-edittext android-tablelayout


    【解决方案1】:

    这将 100% 工作.....

    ScrollView sv=(ScrollView) findViewById(R.id.scrollView1);

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-27
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多