问题
You will see a flickering issue on edit text boxes when you try to scroll. This is an issue often seen and is due to bad coding while creating View using XML. See the following samples on understanding the issue.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/stepText"
android:background="@drawable/textbox_group_border"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/emailArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
**android:background="@color/color_white"**
>
<EditText
android:id="@+id/emailEditText"
android:layout_width="fill_parent"
android:layout_height="45dip"
**android:background="@color/color_white"**
android:hint="@string/email_address"
android:inputType="textEmailAddress"
android:paddingLeft="5dip"
android:paddingRight="55dp"
android:tag="Email Address"
android:textColor="#FF777777"
android:textColorHint="@color/hint_color"
android:textSize="15dip" />
<TextView
android:id="@+id/whyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingRight="10dip"
android:text="@string/why_statement"
android:textColor="#2388A5"
android:textSize="14dip" />
</RelativeLayout>
<!--Other Layouts-->
</LinearLayout>
回答1:
In the sample above in the question, background has been set to color WHITE for email in both emailEditText and emailArea. This is the reason for flickering. To avoid this flickering just set background to white at one place only. See the following code :-
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/stepText"
android:background="@drawable/textbox_group_border"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/emailArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
**android:background="@color/color_white"**
>
<EditText
android:id="@+id/emailEditText"
android:layout_width="fill_parent"
android:layout_height="45dip"
**android:background="@null"**
android:hint="@string/email_address"
android:inputType="textEmailAddress"
android:paddingLeft="5dip"
android:paddingRight="55dp"
android:tag="Email Address"
android:textColor="#FF777777"
android:textColorHint="@color/hint_color"
android:textSize="15dip" />
<TextView
android:id="@+id/whyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingRight="10dip"
android:text="@string/why_statement"
android:textColor="#2388A5"
android:textSize="14dip" />
</RelativeLayout>
<!--Other Layouts-->
</LinearLayout>
回答2:
maybe i could help you as i understood from your question when you are scrolling the color changed.
just put
android:fadescrollbars="false";
that's it
hope it helped my friend
来源:https://stackoverflow.com/questions/16981905/this-is-a-solution-for-flickering-issue-on-scrolling-on-android-device