2012-12-02 3 views
1

내 웹보기가 아무 문제없이 잘 표시됩니다. 그러나 "선택한 텍스트"기능을 적용하면 웹보기가 화면 절반에만 표시됩니다 (아래 이미지 참조). 내가 잘못 한 일을 아무 생각Android WebView가 절반 화면에만 표시됩니다.

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.content); 

    Intent i = this.getIntent(); 

    final int wordId = i.getIntExtra("id", -1); 
    mCurrentWord = i.getStringExtra("word"); 
    mSelectedDB = i.getStringExtra("db"); 
    mContentStyle = i.getStringExtra("style"); 

    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); 

    loadHistoryFromPreferences(); 
    loadFavouriteFromPreferences(); 

    wvContent = (WebView) findViewById(R.id.wvContent); 
    initWebview(); 
    String content = getContentById(wordId); 
    showContent(content); 

    //This is the beginning of what I added 
    webkit=new Webkit(this); 
    wvContent.addView(webkit); 
    WebkitSelectedText webkitSelectedText=new WebkitSelectedText(getApplicationContext(), webkit); 
    webkitSelectedText.init(); 

    wvContent.setOnClickListener(new View.OnClickListener() {   
     @Override 
     public void onClick(View v) { 
      finish(); 
     } 
    }); 
    //This is the end of what I added 

:

enter image description here

여기 내 코드입니다. 이 디스플레이 문제를 제외하고 새로 추가 된 것을 포함하여 다른 모든 기능은 Selected text 잘 작동합니다.

여러분이 문제를 인식하고 해결할 수 있기를 바랍니다. 고맙습니다.

<?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:gravity="bottom|fill_vertical" 
> 
    <LinearLayout xmlns:android= 
    "http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="vertical" 
    android:layout_weight="1" 
    >  
    <WebView 
     android:id="@+id/wvContent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="top" 
     android:layout_weight="1" 
    /> 

</LinearLayout> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:orientation="horizontal" 
> 
    <ImageButton 
     android:id="@+id/btnHome" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:src="@drawable/home" 
     android:layout_weight="0.25" 
    /> 
    <ImageButton 
     android:id="@+id/btnPronounce" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:src="@drawable/pronounce" 
     android:layout_weight="0.25" 
    />  
    <ImageButton 
     android:id="@+id/btnShowHistory" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:src="@drawable/history" 
     android:layout_weight="0.25" 
    /> 
    <ImageButton 
     android:id="@+id/btnAddFavourite" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:src="@drawable/add_favourite" 
     android:layout_weight="0.25" 
    /> 
</LinearLayout> 

답변

0

문제가 레이아웃 될 수도있다 : 여기

편집

레이아웃이다.

res/layout의 content.xml에는 webview의 android : layout_height 속성을 fill_parent로 설정해야합니다.

해결해야합니다. 그렇지 않으면 레이아웃의 내용도 붙여 넣으십시오. 그리고 우리는이 비슷한 문제 여부와 사람을 도움이 될 수있는 경우

+0

감사합니다. 이미 "fill_parent"로 설정했습니다. 하지만 EDITED에서 내 레이아웃을 살펴 보시기 바랍니다. –

+0

content.xml의 코드를 붙여주세요. – nithinreddy

+0

그럼 누구나 문제를 파악할 수 있습니까? 도움을 받으십시오. –

0

는 잘 모르겠어요 할 수 있지만 결국 나는 변경하여 내 문제를 해결 :

wvContent.addView(webkit); 

wvContent.addView(webkit,0,0); 

에 솔루션이 아니라 해결 방법 일 것입니다.

0

저도 같은 문제를 점점 생각했다 나는 WebViewClient에 다음 코드로 고정 :

webView.setVisibility(View.VISIBLE); 

내 문제는 내가 클릭으로는 즉시, 첫 번째로드에 반 화면을 표시이었다 메뉴를 변경하거나 장치의 방향을 변경하면보기가 전체 화면으로 다시 그려집니다. Visible로 설정하면 그 수정을 다시 그려야합니다.

관련 문제