I have my android webView app working nice. It also shows the ProgressBar while loading the url and hides it when finish the load with a beautiful effect cause I put some alpha in the ProgressBar layout to see webView in the background. I followed this example..
My problem is: webView is still clickable.
MyManifest.xml
: i have all permissions needed I think...
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainLayout"
tools:context="com.siconet.axa.MainActivity" >
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<ProgressBar
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:indeterminate="true" />
</RelativeLayout>
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Then I show/hide progressbar in the client and I need to avoid webView from being clicked:
webViewClient.java
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
loadingFinished = false;
// this works like charm
activity.findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE);
activity.findViewById(R.id.webView).setAlpha(0.3f);
// this is not working :(
activity.findViewById(R.id.loadingPanel).setClickable(true);
activity.findViewById(R.id.webView).setClickable(false);
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url)
{
// control of the loading options....
if (loadingFinished && !redirect) {
activity.findViewById(R.id.loadingPanel).setVisibility(View.GONE);
activity.findViewById(R.id.webView).setAlpha(1f);
// not working again :(
activity.findViewById(R.id.loadingPanel).setClickable(false);
activity.findViewById(R.id.webView).setClickable(true);
}
}
I also tried with requestFocus():
activity.findViewById(R.id.loadingPanel).requestFocus();
And adding listeners to the views:
mWebView.setOnTouchListener(new OnTouchListener() { // declare listener...
Any idea of why is this happening???