Issue
I'm using this lib for horizontal swipe. Check the below code
Swipe functionality works fine but when i'm going direct to slide then doesn't show content on web view. Shown some below pic for more detail:-
After above pic when ever i'm swipe it works nice but when we want to going directly into next slide then facing content disappear problem shown below :-
and then it shows below
code
PageControl mPageControl = (PageControl) findViewById(R.id.page_control);
mSwipeView = (SwipeView) findViewById(R.id.swipe_view);
mSwipeView.setPageControl(mPageControl);
for (int i = 0; i < 10; i++) {
mSwipeView.addView(new FrameLayout(this));
}
for (int i = 0; i < 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 all the things in which 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" >
// some 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" >
// some stuff
</LinearLayout>
also inflate xml on "@+id/option_main" with 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 but facing problem when going one slide to different slide directly.
help me if you have also face same kind of problem in past.
Solution
This the above problem of flickering so i can read so many link like :-
https://code.google.com/p/android/issues/detail?id=20446
hardware accelerated webview slide-in animation flickering on ICS
WebView "flashing" with white background if hardware acceleration is enabled (Android 3.0+)
and
Code
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
above code work for me .
Answered By - duggu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.