web view content flickering in android? -
i'm using this lib horizontal swipe. check below code
swipe functionality works fine when i'm going direct slide doesn't show content on web view. shown below pic more detail:-
after above pic when ever i'm swipe works nice when want going directly next slide facing content disappear problem shown below :-
and shows below
code
pagecontrol mpagecontrol = (pagecontrol) findviewbyid(r.id.page_control); mswipeview = (swipeview) findviewbyid(r.id.swipe_view); mswipeview.setpagecontrol(mpagecontrol); (int = 0; < 10; i++) { mswipeview.addview(new framelayout(this)); } (int = 0; < 10; i++) { ((framelayout) mswipeview.getchildcontainer().getchildat(i)) .addview(setupview()); count++; }
setupview()
public view setupview() { layoutinflater layoutinflator = getlayoutinflater(); linearlayout childlayout = (linearlayout) layoutinflator.inflate( r.layout.webview, switcher, false); // adding things in define in below xml return childlayout; }
xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rootview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/white" android:orientation="vertical" > <scrollview android:id="@+id/scroll" android:layout_width="fill_parent" android:layout_height="wrap_content" > <linearlayout android:id="@+id/main_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="vertical" > <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <linearlayout android:id="@+id/layclick" android:layout_width="43dp" android:layout_height="64dp" android:background="@drawable/queslay" android:gravity="left" android:orientation="vertical" > // stuff </linearlayout> <linearlayout android:id="@+id/main_question" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <webview android:id="@+id/ques" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffffff" /> </linearlayout> </linearlayout> <linearlayout android:id="@+id/option_main" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" > </linearlayout> </linearlayout> </scrollview> <linearlayout android:id="@+id/solution_confirm" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="@null" android:gravity="center" android:orientation="horizontal" > // stuff </linearlayout>
also inflate xml on "@+id/option_main" below xml :
<?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="wrap_content" android:orientation="vertical" > <!-- <fl><ll><fl></fl><btn/></ll></fl> --> <relativelayout android:id="@+id/option_relative_a" android:layout_width="fill_parent" android:layout_margin="10dp" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:id="@+id/option_a" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="40dp" android:layout_height="wrap_content" android:orientation="vertical" > <button android:id="@+id/btn_a" android:layout_width="47dp" android:layout_height="19dp" android:layout_gravity="center_horizontal" android:background="@drawable/opgrey" android:gravity="center" android:text="@string/a" android:textcolor="#ffffff" android:textsize="12sp" /> <imageview android:id="@+id/ch_a" android:layout_width="21dp" android:layout_height="18dp" android:layout_margintop="5dp" android:layout_gravity="center_horizontal" android:src="@drawable/cross" android:gravity="center" android:textsize="12sp" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginbottom="2dp" android:layout_marginright="2dp" android:layout_margintop="2dp" android:orientation="vertical" > <webview android:id="@+id/ques_option_a" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> </linearlayout> <imageview android:id="@+id/option_image_a" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignbottom="@+id/option_a" android:background="@null" /> </relativelayout> <relativelayout android:id="@+id/option_relative_b" android:layout_width="fill_parent" android:layout_margin="10dp" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:id="@+id/option_b" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="40dp" android:layout_height="wrap_content" android:orientation="vertical" > <button android:id="@+id/btn_b" android:layout_width="47dp" android:layout_height="19dp" android:layout_gravity="center_horizontal" android:background="@drawable/opgrey" android:gravity="center" android:text="@string/b" android:textcolor="#ffffff" android:textsize="12sp" /> <imageview android:id="@+id/ch_b" android:layout_width="21dp" android:layout_height="18dp" android:layout_margintop="5dp" android:layout_gravity="center_horizontal" android:src="@drawable/cross" android:gravity="center" android:textsize="12sp" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginbottom="2dp" android:layout_marginright="2dp" android:layout_margintop="2dp" android:orientation="vertical" > <webview android:id="@+id/ques_option_b" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> </linearlayout> <imageview android:id="@+id/option_image_b" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignbottom="@+id/option_b" android:background="@null" /> </relativelayout> <relativelayout android:id="@+id/option_relative_c" android:layout_width="fill_parent" android:layout_margin="10dp" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:id="@+id/option_c" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="40dp" android:layout_height="wrap_content" android:orientation="vertical" > <button android:id="@+id/btn_c" android:layout_width="47dp" android:layout_height="19dp" android:layout_gravity="center_horizontal" android:background="@drawable/opgrey" android:gravity="center" android:text="@string/c" android:textcolor="#ffffff" android:textsize="12sp" /> <imageview android:id="@+id/ch_c" android:layout_width="21dp" android:layout_margintop="5dp" android:layout_height="18dp" android:layout_gravity="center_horizontal" android:src="@drawable/cross" android:gravity="center" android:textsize="12sp" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginbottom="2dp" android:layout_marginright="2dp" android:layout_margintop="2dp" android:orientation="vertical" > <webview android:id="@+id/ques_option_c" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> </linearlayout> <imageview android:id="@+id/option_image_c" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignbottom="@+id/option_c" android:background="@null" /> </relativelayout> <relativelayout android:id="@+id/option_relative_d" android:layout_width="fill_parent" android:layout_margin="10dp" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:id="@+id/option_d" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="40dp" android:layout_height="wrap_content" android:orientation="vertical" > <button android:id="@+id/btn_d" android:layout_width="47dp" android:layout_height="19dp" android:layout_gravity="center_horizontal" android:background="@drawable/opgrey" android:gravity="center" android:text="@string/d" android:textcolor="#ffffff" android:textsize="12sp" /> <imageview android:id="@+id/ch_d" android:layout_width="21dp" android:layout_height="18dp" android:layout_margintop="5dp" android:layout_gravity="center_horizontal" android:src="@drawable/greentick" android:gravity="center" android:textsize="12sp" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginbottom="2dp" android:layout_marginright="2dp" android:layout_margintop="2dp" android:orientation="vertical" > <webview android:id="@+id/ques_option_d" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> </linearlayout> <imageview android:id="@+id/option_image_d" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_alignbottom="@+id/option_d" android:background="@null" /> </relativelayout> <relativelayout android:id="@+id/option_relative_e" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="horizontal" > <linearlayout android:id="@+id/option_e" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="40dp" android:layout_height="wrap_content" android:orientation="vertical" > <button android:id="@+id/btn_e" android:layout_width="47dp" android:layout_height="19dp" android:layout_gravity="center_horizontal" android:background="@drawable/opgrey" android:gravity="center" android:text="@string/e" android:textcolor="#ffffff" android:textsize="12sp" /> <imageview android:id="@+id/ch_e" android:layout_width="21dp" android:layout_height="18dp" android:layout_margintop="5dp" android:layout_gravity="center_horizontal" android:src="@drawable/greentick" android:gravity="center" android:textsize="12sp" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginbottom="2dp" android:layout_marginright="2dp" android:layout_margintop="2dp" android:orientation="vertical" > <webview android:id="@+id/ques_option_e" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> </linearlayout> <imageview android:id="@+id/option_image_e" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignbottom="@+id/option_e" android:background="@null" /> </relativelayout>
swipe working fine facing problem when going 1 slide different slide directly.
help me if have face same kind of problem in past.
this above problem of flickering can read many link :-
https://code.google.com/p/android/issues/detail?id=20446
hardware accelerated webview slide-in animation flickering on ics
webview "flashing" white background if hardware acceleration enabled (android 3.0+)
and
code
webview.setlayertype(view.layer_type_software, null);
above code work me .
Comments
Post a Comment