Reputation: 127
Im trying to create a web view that enables it to fill the whole screen if the toolbar is gone. The code I used came up with no errors but doesn't display what I want rather its smaller then it was prior and am wondering if there is a better way or a more in-depth way.
The code I am using is as follows
mToolbar.setVisibility(View.GONE);
if(mToolbar.getVisibility() == View.GONE){
int mTb = 0;
mWebView.requestLayout();
mWebView.getLayoutParams().height = 567;
}
I would like a more complex solution for reasons that I haven't reached yet in production
Upvotes: 2
Views: 87
Reputation: 12953
dynamically you can fit Webview
to screen using
if(mToolbar.getVisibility() == View.GONE){
int mTb = 0;
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
mWebView.setLayoutParams(layoutParams);
mWebView.requestLayout();
}
Upvotes: 0
Reputation: 624
in xml write like this
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
and remove this in java code
if(mToolbar.getVisibility() == View.GONE){
int mTb = 0;
mWebView.requestLayout();
mWebView.getLayoutParams().height = 567;
}
Upvotes: 1