2011-11-04 2 views
0

내 레이아웃에 웹보기를 추가하고 싶습니다.하지만 그 레이아웃에는 다른 위젯도 몇 개 있습니다.하지만 애플리케이션을 실행할 때 webview는 전체 화면을 가져 가고 다른 위젯은 사라집니다. 여기 내 레이아웃에서 page.xml .... 위젯이 더 많은 레이아웃에 웹보기를 추가하는 방법

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" > 

<WebView android:layout_width="match_parent" android:layout_height="200dp" android:id="@+id/web"></WebView> 

<View android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:layout_height="2px" android:background="#ffffff" android:layout_width="fill_parent" ></View> 

<TextView android:text="Simple text view" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 


</LinearLayout> 

과 뷰와 텍스트 뷰를 표시하지 않고 웹보기 전체 screen.Please 얻을

setContentView(R.layout.page); 

    WebView wv1=(WebView)findViewById(R.id.web); 
    wv1.loadUrl("http://google.com"); 

활동 클래스의

나를 내가 무엇을 보여이다 여기서 잘못하고있는거야. 아니면 내가해야 할 올바른 길은 뭐지. 감사합니다.

+1

당신이 대답 http://stackoverflow.com/questions/3382188/how-to-set-webview-as-non-fullscreen –

+0

감사의 Hossain을 얻을 수있는, 내가 생각하는 문제를 만들 리디렉션 그곳에. google.com이 google.lk로 리디렉션되면 브라우저가 나를 미쳐 버립니다. – sampathpremarathna

답변

1

WebViewClient을 설정하면 문제가 해결됩니다. 다음 텍스트 뷰의 VILL가 botton을에 표시이처럼 XML은, 뷰가 텍스트 뷰 위에 표시됩니다

/** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     WebView wv1=(WebView)findViewById(R.id.web1); 
     wv1.setWebViewClient(new myClient()); 
     wv1.loadUrl("http://google.com"); 
    } 

    class myClient extends WebViewClient 
    { 
     @Override 
     public void onPageFinished(WebView view, String url) { 
      // TODO Auto-generated method stub 
      super.onPageFinished(view, url); 
     } 

     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 
      // TODO Auto-generated method stub 

      view.loadUrl(url); 
      return true; 
     } 

     @Override 
     public void onReceivedError(WebView view, int errorCode, 
       String description, String failingUrl) { 
      // TODO Auto-generated method stub 
      super.onReceivedError(view, errorCode, description, failingUrl); 
     } 
    } 
0

변화는 웹보기는 나머지 spase에 표시됩니다. CommonsWare 말했듯이 여기

<RelativeLayout 
    ... 
> 
<TextView 
    android:layout_alignParentBottom="true" 
    android:id="@+id/sample_text" 
    ... 
/> 
<View 
    android:layout_above="@id/sample_text" 
    android:id="@+id/sample_view" 
    ... 
> 
<WebView 
    android:layout_above="@id/sample_view" 
    ... 
/> 
</RelativeLayout> 
관련 문제