0

I 've a LinearLayout with 2 views, view A which takes some vertical space, and view B which takes the rest of the layout.

<LinearLayout

        android:id="@+id/ly2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/input"
        android:orientation="vertical" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="50dp" >
        </View>

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
</LinearLayout>

At some point I want to remove view A. How do I tell LinearLayout to refresh so view B takes the entire space?

Best Regards.

Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78

2 Answers2

3
View v=(View)findViewById(R.id.view1);

at some point use

v.setVisibility(View.GONE);

see this link for more help

Community
  • 1
  • 1
N J
  • 27,217
  • 13
  • 76
  • 96
2

try to replace your xml with this code

<RelativeLayout

        android:id="@+id/ly2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="50dp" >
        </View>

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>

In your main activity where this xml is used put this

View view=(View)findViewById(R.id.view1);
view.setVisibility(View.GONE);
Maniya Joe
  • 761
  • 6
  • 24