1

in below code i used a webview, but when i set visibility to invisible or gone, it dose not work and always is visible, why?

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent" >

    <GridView
        android:id="@+id/gridView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="160dp"
        android:layoutAnimation="@anim/layout_item_fade_in"
        android:numColumns="3" >
    </GridView>

    <WebView
        android:id="@+id/webView1"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
</RelativeLayout>
mbagher
  • 387
  • 4
  • 14

3 Answers3

2

Oh, I've found my answer.

I override onPageFinished method, and in that I used setVisibility(View.Visibile), so after some seconds it runs and WebView goes visible. So be careful about threads.

Artem Mostyaev
  • 3,874
  • 10
  • 53
  • 60
mbagher
  • 387
  • 4
  • 14
0

Try this code

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
  <GridView
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="160dp"
    android:layoutAnimation="@anim/layout_item_fade_in"
    android:numColumns="3" >
</GridView>

<WebView
    android:id="@+id/webView1"
    android:visibility="gone"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />
</RelativeLayout>
sud
  • 505
  • 1
  • 4
  • 12
  • 1
    this code works for grideView but dose not work for webView – mbagher Oct 27 '15 at 09:01
  • clean the project and try again sometimes it will help... select project then go to **option** from toolbar select **clean**... – sud Oct 27 '15 at 09:07
  • make your **Relative Layout** `width` as `fill_parent` or `wrap_content` – sud Oct 27 '15 at 09:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/93460/discussion-between-sud-and-user1615184). – sud Oct 27 '15 at 09:26
0

in xml

<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"    
    android:layout_alignParentBottom="true"  />

in code:

Webview webview =  (Webview)findViewById(R.id.webview1);
webview.setVisibility(View.INVISIBLE);

and please show where you set visibility ?

Ahmad Alkhatib
  • 1,230
  • 2
  • 14
  • 31