Reputation: 23596
I going to hide and show the Layout onclick of the webview.
I have code like below:
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.backButton:
finish();
break;
case R.id.webView:
if(bottomShow){
bottomLayout.setVisibility(View.GONE);
bottomShow = false;
}
else{
bottomLayout.setVisibility(View.VISIBLE);
bottomShow = true;
}
break;
}
}
I have also set the clickListener as like
webView.setOnClickListener(this);
but even after doing that i am not getting any effect.
Why i am not able to get action on click on the webview ??
After Somehelp i have try it onTouchListener like below:
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(v.getId()){
case R.id.webView:
if(event.getAction() == MotionEvent.ACTION_UP){
//Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show();
if(bottomShow){
bottomLayout.setVisibility(View.GONE);
bottomShow = false;
}
else{
bottomLayout.setVisibility(View.VISIBLE);
bottomShow = true;
}
return true;
}
break;
}
return false;
}
Now it works but webView is not smoothly scrolling as it does before.
So whats the proper solution for that ? or whats wrong in my code if it is ??
Please help me.
Thanks.
Upvotes: 2
Views: 8193