Sayed Jalil Hassan
Sayed Jalil Hassan

Reputation: 2595

Run time layout setup in android

I have an android layout which has a webView and a View inside it. i decide at Run time whether to display the webview or not and if not then the other View should fill the parent background. Also i would want the webView to appear at the bottom and for that i have set the layout_gravity to bottom but it doesn't work.
Here is what my xml looks like :

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="vertical"
       android:weightSum="1" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_gravity="bottom" />

    <View
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </View>
    </LinearLayout>    

Upvotes: 0

Views: 130

Answers (2)

Jonathan
Jonathan

Reputation: 3457

In terms of making the View disappear setting the visibility through something like

WebView myWebview = (WebView) findViewById(R.id.web_view_id);
myWebview.setVisibility(View.GONE);

Will do the trick. As for laying it out at the bottom of your view, LinearLayout lays out items in the order that they are given, so just move your LinearLayout below your other View and it should layout properly.

Upvotes: 0

KOTIOS
KOTIOS

Reputation: 11194

You should use visiblity gone property that will work

Upvotes: 1

Related Questions