带有EditText的Android窗体使屏幕闪烁 [英] Android Form with EditText makes the screen flash
问题描述
我不知道为什么在聚焦EditText然后滚动布局时为什么"Forms"活动会闪烁. 这只会发生在搭载Android 4.0以上版本的装置中 我正在使用表布局并动态添加TableRow.
I don't know why my "Forms" activity are flashing when an EditText are focused and then a layout is scrolled. It just happen in devices with Android 4.0 + I am using a Table Layout and adding TableRow dynamically.
我的TableRow是这样的:
My TableRow is like that:
<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中....
Then,I add the TableRow into a 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充气
Then,in the code, i inflate my 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.
And a lot of TableRow are added.
问题是...
为什么滚动表单时我的表单会闪烁(闪烁)?为何只在Android 4.0以上版本中会发生这种情况?
Why are my Form flashing( blinking) when I scroll it? And Why does it happen only in Android 4.0 +?
我已经看过这篇文章.... http://android-developers .blogspot.com.br/2009/01/why-is-my-list-black-android.html 但我不能使用ListView.
I already saw this post .... http://android-developers.blogspot.com.br/2009/01/why-is-my-list-black-android.html but I am not working with ListView.
我已经尝试过
android:cacheColorHint="#00000000"
在TableLayout中,但是没有用.
in the TableLayout but, it didn't work.
推荐答案
这将100%起作用.....
This will 100% work .....
ScrollView sv =(ScrollView)findViewById(R.id.scrollView1);
ScrollView sv=(ScrollView) findViewById(R.id.scrollView1);
sv.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
edttext.clearFocus();
return false;
}
});
这篇关于带有EditText的Android窗体使屏幕闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!