How to set WebView inside a LinearLayout
android, android-layout
Solution
you need to set the orientation of `LinearLayout` to `vertical`, the default is `horizontal`
Problem
I am trying to set webview inside a linearlayout. I have just created an xml Linear layout file, progress bar and a webview inside the linear layout.. ``` <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="match_parent" > <ProgressBar android:id="@+id/progWeb" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/darker_gray" android:max="100" android:visibility="invisible" /> <WebView android:id="@+id/web" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> ``` and java file it shows progress bar only. Webview is not shown by this code ``` public class MainActivity extends Activity { private WebView web; private ProgressBar progBar; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_main); web = (WebView) findViewById(R.id.web); progBar = (ProgressBar) findViewById(R.id.progWeb); progBar.setVisibility(ProgressBar.INVISIBLE); String url = "http://www.google.com.pk/"; web.getSettings().setJavaScriptEnabled(true); web.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { System.out.println(progress); progBar.setProgress(progress); if (progress == 100) { progBar.setVisibility(ProgressBar.INVISIBLE); progBar.setProgress(0); } else { progBar.setVisibility(ProgressBar.VISIBLE); } } }); web.loadUrl(url); } } ```