2016-07-22 6 views
0

Navigation Drawerでアプリを作成しました。タブに切り替えた場合(この場合はWebView)、WebViewは正しく表示されません。 Picture (area is marked)WebViewが正しく表示されない

フラグメント:

public class StudentPlanFragment extends Fragment { 

private WebView mWebView; 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    View rootView = inflater.inflate(R.layout.fragment_student_plan, null); 
    mWebView = (WebView) rootView .findViewById(R.id.webViewStudentPlan); 
    mWebView.loadUrl("http://example.com"); 
    mWebView.getSettings().setJavaScriptEnabled(true); 


    return rootView ; 
} 
} 

私のXML-ファイル:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="de.nichuhn.hlg.StudentPlanFragment" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:id="@+id/constraintLayout"> 


<WebView 
    android:layout_width="match_parent" 
    android:id="@+id/webViewStudentPlan" 
    tools:layout_editor_absoluteY="0dp" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentEnd="true" /> 

</RelativeLayout> 
+0

でのインターネットのアクセス許可を確認しN.Preusche –

答えて

0

まず、なぜあなたはRelativeLayout使うのですか? WebViewだけを使用している場合:

<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/webViewStudentPlan" 
tools:layout_editor_absoluteY="0dp" /> 

問題はバーの上部または下部にありますか?

+0

下@私の解決策を確認し、それが絵の上にマークされています。 –

+0

レイアウトを置き換えようとしましたか?はいの場合は、ナビゲーションドロワーのレイアウトを追加してください – Timo

0

mWebView = (WebView) rootView .findViewById(R.id.webViewStudentPlan); 
mWebView.getSettings().setJavaScriptEnabled(true); 
mWebView.loadUrl("http://example.com"); 

loadUrlが最後である、である、この方法を試してみてください。

もごmanifest.xml

、などの
<uses-permission android:name="android.permission.INTERNET" /> 
関連する問題