示範
先新增Assect Folder->Finish
接著新增File->index.html
XML
xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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"> <WebView android:id="@+id/webv" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> android.support.constraint.ConstraintLayout>
JAVA
public class MainActivity extends AppCompatActivity{ WebView webv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String myuri="file:///android_asset/index.html"; webv=(WebView)findViewById(R.id.webv); webv.getSettings().setJavaScriptEnabled(true); webv.loadUrl(myuri); } }