Issue
- When should I create a WebView programmatically and when just inflate it by using findViewById()?
- What are the advantages / disadvantages?
- Which layout should I use as the parent layout when I just need one View?
Solution
- I would create it programmatically if you only need it for very short periods and not very often. Most of the time I always go with the findViewById() route.
- The main advantage with inflating it is that it can be easier to tweak little settings and easier to troubleshoot issues. But your mileage will vary.
- I use FrameLayout so I can add a progressbar over top like so;
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/sup_launcher">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:id="@+id/webView"/>
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"/>
</FrameLayout>
Answered By - opt05
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.