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>
でのインターネットのアクセス許可を確認しN.Preusche –